Issue #456 - Add 'Info:' message when charset replaced

This commit is contained in:
Geoff McLane 2017-06-05 17:16:53 +02:00
parent a4770daa2b
commit 97292646f6
4 changed files with 9 additions and 2 deletions

View file

@ -169,6 +169,7 @@ extern "C" {
FN(BACKSLASH_IN_URI) \
FN(BAD_ATTRIBUTE_VALUE_REPLACED) \
FN(BAD_ATTRIBUTE_VALUE) \
FN(ATTRIBUTE_VALUE_REPLACED) \
FN(ESCAPED_ILLEGAL_URI) \
FN(FIXED_BACKSLASH) \
FN(ID_NAME_MISMATCH) \

View file

@ -2371,8 +2371,8 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
TY_(tmbstrcpy)(newValue, enc);
/* Note: previously http-equiv had been modified, without warning
in void TY_(VerifyHTTPEquiv)(TidyDocImpl* doc, Node *head)
TY_(ReportAttrError)( doc, currentNode, charsetAttr, BAD_ATTRIBUTE_VALUE_REPLACED );
*/
TY_(ReportAttrError)(doc, currentNode, charsetAttr, ATTRIBUTE_VALUE_REPLACED);
TidyDocFree(doc, charsetAttr->value); /* free current value */
charsetAttr->value = newValue;
}
@ -2450,9 +2450,10 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
{
/* correct the content */
newValue = (tmbstr)TidyDocAlloc(doc, 19 + TY_(tmbstrlen)(enc) + 1);
TidyDocFree(doc, contentAttr->value);
TY_(tmbstrcpy)(newValue, "text/html; charset=");
TY_(tmbstrcpy)(newValue + 19, enc);
TY_(ReportAttrError)(doc, currentNode, contentAttr, ATTRIBUTE_VALUE_REPLACED);
TidyDocFree(doc, contentAttr->value);
contentAttr->value = newValue;
charsetFound = yes;
}

View file

@ -1798,6 +1798,7 @@ static languageDefinition language_en = { whichPluralForm_en, {
{ BACKSLASH_IN_URI, 0, "%s URI reference contains backslash. Typo?" }, /* ReportAttrError */
{ BAD_ATTRIBUTE_VALUE_REPLACED, 0, "%s attribute \"%s\" had invalid value \"%s\" and has been replaced" }, /* ReportAttrError */
{ BAD_ATTRIBUTE_VALUE, 0, "%s attribute \"%s\" has invalid value \"%s\"" }, /* ReportAttrError */
{ ATTRIBUTE_VALUE_REPLACED, 0, "%s attribute \"%s\", incorrect value \"%s\" replaced" }, /* ReportAttrError/TidyInfo */
{ ESCAPED_ILLEGAL_URI, 0, "%s escaping malformed URI reference" }, /* ReportAttrError */
{ FIXED_BACKSLASH, 0, "%s converting backslash in URI to slash" }, /* ReportAttrError */
{ ID_NAME_MISMATCH, 0, "%s id and name attribute value mismatch" }, /* ReportAttrError */

View file

@ -526,6 +526,10 @@ void TY_(ReportAttrError)(TidyDocImpl* doc, Node *node, AttVal *av, uint code)
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, tagdesc, name, value );
break;
case ATTRIBUTE_VALUE_REPLACED:
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyInfo, tagdesc, name, value);
break;
case UNEXPECTED_QUOTEMARK:
case MISSING_QUOTEMARK:
case ID_NAME_MISMATCH: