Issue #207 - deal with 2 cases of an unambiguous ampersand.

html5 allows a naked ampersand unquoted, and now tidy will not issue a
warning. This only deals with a & b, and P&<li>O</li>

More may need to be done for other cases.
This commit is contained in:
Geoff McLane 2015-06-24 13:05:06 +02:00
parent b65988c95a
commit 3a524f1710
2 changed files with 18 additions and 2 deletions

View file

@ -1055,10 +1055,18 @@ static void ParseEntity( TidyDocImpl* doc, GetTokenMode mode )
if (semicolon)
TY_(AddCharToLexer)( lexer, ';' );
}
else /* naked & */
else
{
/*\
* Issue #207 - A naked & is allowed in HTML5, as an unambiguous ampersand!
\*/
if (TY_(HTMLVersion)(doc) != HT50)
{
TY_(ReportEntityError)( doc, UNESCAPED_AMPERSAND,
lexer->lexbuf+start, ch );
}
}
}
else
{
if ( c != ';' ) /* issue warning if not terminated by ';' */

View file

@ -982,6 +982,14 @@ static void PPrintText( TidyDocImpl* doc, uint mode, uint indent,
ixWS = TextStartsWithWhitespace( doc->lexer, node, ix+1, mode );
ix = IncrWS( ix, end, indent, ixWS );
}
else if (( c == '&' ) && (TY_(HTMLVersion)(doc) == HT50) &&
(((ix + 1) == end) || ((ix + 1) < end) && (isspace(doc->lexer->lexbuf[ix+1]))) )
{
/*\
* Issue #207 - This is an unambiguous ampersand need not be 'quoted' in HTML5
\*/
PPrintChar( doc, c, (mode | CDATA) );
}
else
{
PPrintChar( doc, c, mode );