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(COERCE_TO_ENDTAG) \
FN(ELEMENT_NOT_EMPTY) \ FN(ELEMENT_NOT_EMPTY) \
FN(UNEXPECTED_END_OF_FILE) \ 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. */ /** 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, "text/html; ", 11);
tidyBufAppend(&buf, charsetString.bp, TY_(tmbstrlen)(charsetString.bp)); tidyBufAppend(&buf, charsetString.bp, TY_(tmbstrlen)(charsetString.bp));
tidyBufAppend(&buf, "\0", 1); /* zero terminate the buffer */ 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); tidyBufFree(&buf);
} }
TY_(InsertNodeAtStart)(head, metaTag); TY_(InsertNodeAtStart)(head, metaTag);
TY_(ReportError)(doc, metaTag, head, ADDED_MISSING_CHARSET); /* actually just 'Info:' */
} }
tidyBufFree(&charsetString); tidyBufFree(&charsetString);
return yes; return yes;

View file

@ -1901,6 +1901,8 @@ static languageDefinition language_en = { whichPluralForm_en, {
{ UNEXPECTED_END_OF_FILE, 0, "unexpected end of file %s" }, /* ReportError, ReportAttrError */ { UNEXPECTED_END_OF_FILE, 0, "unexpected end of file %s" }, /* ReportError, ReportAttrError */
{ UNEXPECTED_ENDTAG, 0, "unexpected </%s>" }, /* ReportError, ReportFatal */ { UNEXPECTED_ENDTAG, 0, "unexpected </%s>" }, /* ReportError, ReportFatal */
{ ADDED_MISSING_CHARSET, 0, "Added appropriate missing <meta charset=...> to %s" }, /* ReportInfo */
#if SUPPORT_ACCESSIBILITY_CHECKS #if SUPPORT_ACCESSIBILITY_CHECKS
/*************************************** /***************************************

View file

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