Issue #456 - Add 'Info:' message, when meta added.

It also fixes the addition of the constant 'http-equiv="Content-Type"
attribute.
This commit is contained in:
Geoff McLane 2017-06-04 20:34:22 +02:00
parent 13b34c9d8b
commit a4770daa2b
4 changed files with 13 additions and 3 deletions

View File

@ -270,7 +270,8 @@ extern "C" {
FN(COERCE_TO_ENDTAG) \
FN(ELEMENT_NOT_EMPTY) \
FN(UNEXPECTED_END_OF_FILE) \
FN(UNEXPECTED_ENDTAG)
FN(UNEXPECTED_ENDTAG) \
FN(ADDED_MISSING_CHARSET)
/** These are report messages added by Tidy's accessibility module. */

View File

@ -2489,10 +2489,12 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc)
tidyBufAppend(&buf, "text/html; ", 11);
tidyBufAppend(&buf, charsetString.bp, TY_(tmbstrlen)(charsetString.bp));
tidyBufAppend(&buf, "\0", 1); /* zero terminate the buffer */
TY_(AddAttribute)(doc, metaTag, "content", (char*)buf.bp);
TY_(AddAttribute)(doc, metaTag, "http-equiv", "Content-Type"); /* add 'http-equiv' const. */
TY_(AddAttribute)(doc, metaTag, "content", (char*)buf.bp); /* add 'content="<enc>"' */
tidyBufFree(&buf);
}
TY_(InsertNodeAtStart)(head, metaTag);
TY_(ReportError)(doc, metaTag, head, ADDED_MISSING_CHARSET); /* actually just 'Info:' */
}
tidyBufFree(&charsetString);
return yes;

View File

@ -1900,7 +1900,9 @@ static languageDefinition language_en = { whichPluralForm_en, {
{ ELEMENT_NOT_EMPTY, 0, "%s element not empty or not closed" }, /* ReportError, ReportAttrError */
{ UNEXPECTED_END_OF_FILE, 0, "unexpected end of file %s" }, /* ReportError, ReportAttrError */
{ UNEXPECTED_ENDTAG, 0, "unexpected </%s>" }, /* ReportError, ReportFatal */
{ ADDED_MISSING_CHARSET, 0, "Added appropriate missing <meta charset=...> to %s" }, /* ReportInfo */
#if SUPPORT_ACCESSIBILITY_CHECKS
/***************************************

View File

@ -408,6 +408,11 @@ void TY_(ReportError)(TidyDocImpl* doc, Node *element, Node *node, uint code)
case REMOVED_HTML5:
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyError, nodedesc );
break;
case ADDED_MISSING_CHARSET:
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyInfo, nodedesc);
break;
}
messageOut( message );