From b32e14a8eab1e14bb0e02ee804abe30fc94759d9 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Fri, 9 Jun 2017 03:11:39 +0200 Subject: [PATCH] Issue #456 - add new option `show-meta-change` --- include/tidyenum.h | 1 + src/clean.c | 3 ++- src/config.c | 1 + src/language_en.h | 7 ++++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/tidyenum.h b/include/tidyenum.h index fecce09..f7799d0 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -651,6 +651,7 @@ typedef enum TidyXmlSpace, /**< If set to yes adds xml:space attr as needed */ TidyXmlTags, /**< Treat input as XML */ TidyMetaCharset, /**< Adds/checks/fixes meta charset in the head, based on document type */ + TidyShowMetaChange, /**< show when meta http-equiv content charset was changed - compatibility */ N_TIDY_OPTIONS /**< Must be last */ } TidyOptionId; diff --git a/src/clean.c b/src/clean.c index 819767d..f3f0601 100644 --- a/src/clean.c +++ b/src/clean.c @@ -2452,7 +2452,8 @@ Bool TY_(TidyMetaCharset)(TidyDocImpl* doc) newValue = (tmbstr)TidyDocAlloc(doc, 19 + TY_(tmbstrlen)(enc) + 1); TY_(tmbstrcpy)(newValue, "text/html; charset="); TY_(tmbstrcpy)(newValue + 19, enc); - TY_(ReportAttrError)(doc, currentNode, contentAttr, ATTRIBUTE_VALUE_REPLACED); + if (cfgBool(doc, TidyShowMetaChange)) /* Issue #456 - backward compatibility only */ + TY_(ReportAttrError)(doc, currentNode, contentAttr, ATTRIBUTE_VALUE_REPLACED); TidyDocFree(doc, contentAttr->value); contentAttr->value = newValue; charsetFound = yes; diff --git a/src/config.c b/src/config.c index 8645ec1..a09ecce 100644 --- a/src/config.c +++ b/src/config.c @@ -313,6 +313,7 @@ static const TidyOptionImpl option_defs[] = { TidyXmlSpace, MU, "add-xml-space", BL, no, ParsePickList, &boolPicks }, { TidyXmlTags, MU, "input-xml", BL, no, ParsePickList, &boolPicks }, { TidyMetaCharset, MS, "add-meta-charset", BL, no, ParsePickList, &boolPicks }, /* 20161004 - Issue #456 */ + { TidyShowMetaChange, MS, "show-meta-change", BL, no, ParsePickList, &boolPicks }, /* 20170609 - Issue #456 */ { N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL } }; diff --git a/src/language_en.h b/src/language_en.h index a84b6ed..cd3fae1 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -1522,7 +1522,12 @@ static languageDefinition language_en = { whichPluralForm_en, { be translated. */ TidyMetaCharset, 0, "This option adds a meta element and sets the charset attribute to the encoding of the document." - "Set this option to 'yes' if you want this." + " Set this option to yes if you want this." + }, + { + TidyShowMetaChange, 0, + "This option shows when a meta http-equiv content charset attribute was changed to the encoding of the document." + " Set this option to yes if you want this." }, /********************************************