Issue #348 - Add option 'escape-script', def = yes

This commit is contained in:
Geoff McLane 2016-03-20 01:01:46 +01:00
parent e4bf52c516
commit 000c6925bd
4 changed files with 11 additions and 2 deletions

View file

@ -213,6 +213,7 @@ typedef enum
TidyPPrintTabs, /**< Indent using tabs istead of spaces */
TidySkipNested, /**< Skip nested tags in script and style CDATA */
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
TidyEscapeScripts, /**< Escape items that look like closing tags in script tags */
N_TIDY_OPTIONS /**< Must be last */
} TidyOptionId;

View file

@ -323,6 +323,7 @@ static const TidyOptionImpl option_defs[] =
{ TidyPPrintTabs, PP, "indent-with-tabs", BL, no, ParseTabs, boolPicks }, /* 20150515 - Issue #108 */
{ TidySkipNested, MU, "skip-nested", BL, yes, ParseBool, boolPicks }, /* 1642186 - Issue #65 */
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParseBool, boolPicks }, /* 20160209 - Issue #350 */
{ TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParseBool, boolPicks }, /* 20160227 - Issue #348 */
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
};

View file

@ -2068,6 +2068,11 @@ static languageDefinition language_en = { whichPluralForm_en, {
"<br/>"
"When set to <var>no</var>, these checks are not performed. "
},
{
TidyEscapeScripts, 0,
"This option causes items that look like closing tags, like <code>&lt;/g</code> to be "
"escaped to <code>&lt;\\/g</code>. Set this option to 'no' if you do not want this."
},
/********************************************************
** Console Application

View file

@ -2285,8 +2285,10 @@ static Node *GetCDATA( TidyDocImpl* doc, Node *container )
SetLexerLocus( doc, lexer );
lexer->columns -= 3;
/* if javascript insert backslash before / */
if (TY_(IsJavaScript)(container))
/*\ if javascript insert backslash before /
* Issue #348 - Add option, escape-scripts, to skip
\*/
if ((TY_(IsJavaScript)(container)) && cfgBool(doc, TidyEscapeScripts))
{
/* Issue #281 - only warn if adding the escape! */
TY_(ReportError)(doc, NULL, NULL, BAD_CDATA_CONTENT);