From a4770daa2ba73c7a7fd50acc95d5cfb63992f4c9 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sun, 4 Jun 2017 20:34:22 +0200 Subject: [PATCH] Issue #456 - Add 'Info:' message, when meta added. It also fixes the addition of the constant 'http-equiv="Content-Type" attribute. --- include/tidyenum.h | 3 ++- src/clean.c | 4 +++- src/language_en.h | 4 +++- src/message.c | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/tidyenum.h b/include/tidyenum.h index 95b6e60..bc76cf3 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -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. */ diff --git a/src/clean.c b/src/clean.c index a4eb9fb..76b6acf 100644 --- a/src/clean.c +++ b/src/clean.c @@ -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=""' */ tidyBufFree(&buf); } TY_(InsertNodeAtStart)(head, metaTag); + TY_(ReportError)(doc, metaTag, head, ADDED_MISSING_CHARSET); /* actually just 'Info:' */ } tidyBufFree(&charsetString); return yes; diff --git a/src/language_en.h b/src/language_en.h index f9618c8..b971db1 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -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 " }, /* ReportError, ReportFatal */ - + + { ADDED_MISSING_CHARSET, 0, "Added appropriate missing to %s" }, /* ReportInfo */ + #if SUPPORT_ACCESSIBILITY_CHECKS /*************************************** diff --git a/src/message.c b/src/message.c index 9b86bb5..5330e3e 100755 --- a/src/message.c +++ b/src/message.c @@ -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 );