Merge pull request #382 from htacg/issue-380

Merge Issue 378 and 380
This commit is contained in:
Geoff McLane 2016-03-19 19:28:55 +01:00
commit 370dab3b05
4 changed files with 34 additions and 20 deletions

View file

@ -260,30 +260,32 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, uint code,
if ( go ) if ( go )
{ {
enum { sizeBuf=1024 }; enum { sizeBuf=1024 };
char *buf = TidyDocAlloc(doc,sizeBuf); TidyOutputSink *outp = &doc->errout->sink;
char *buf = (char *)TidyDocAlloc(doc,sizeBuf);
const char *cp; const char *cp;
byte b;
if ( line > 0 && col > 0 ) if ( line > 0 && col > 0 )
{ {
ReportPosition(doc, line, col, buf, sizeBuf); ReportPosition(doc, line, col, buf, sizeBuf);
#if !defined(NDEBUG) && defined(_MSC_VER)
SPRTF("%s",buf);
#endif
for ( cp = buf; *cp; ++cp ) for ( cp = buf; *cp; ++cp )
TY_(WriteChar)( *cp, doc->errout ); {
b = (*cp & 0xff);
outp->putByte( outp->sinkData, b );
}
} }
LevelPrefix( level, buf, sizeBuf ); LevelPrefix( level, buf, sizeBuf );
#if !defined(NDEBUG) && defined(_MSC_VER)
SPRTF("%s",buf);
SPRTF("%s\n",messageBuf);
#else
for ( cp = buf; *cp; ++cp ) for ( cp = buf; *cp; ++cp )
TY_(WriteChar)( *cp, doc->errout ); {
b = (*cp & 0xff);
outp->putByte( outp->sinkData, b );
}
for ( cp = messageBuf; *cp; ++cp ) for ( cp = messageBuf; *cp; ++cp )
TY_(WriteChar)( *cp, doc->errout ); {
b = (*cp & 0xff);
outp->putByte( outp->sinkData, b );
}
TY_(WriteChar)( '\n', doc->errout ); TY_(WriteChar)( '\n', doc->errout );
#endif
TidyDocFree(doc, buf); TidyDocFree(doc, buf);
} }
TidyDocFree(doc, messageBuf); TidyDocFree(doc, messageBuf);

View file

@ -867,7 +867,8 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
#if !defined(NDEBUG) && defined(_MSC_VER) #if !defined(NDEBUG) && defined(_MSC_VER)
in_parse_block++; in_parse_block++;
parse_block_cnt++; parse_block_cnt++;
SPRTF("Entering ParseBlock %d... %d\n",in_parse_block,parse_block_cnt); SPRTF("Entering ParseBlock %d... %d %s\n",in_parse_block,parse_block_cnt,
((element && element->element) ? element->element : ""));
#endif #endif
if ( element->tag->model & CM_EMPTY ) { if ( element->tag->model & CM_EMPTY ) {
@ -943,14 +944,21 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
return; return;
} }
#if OBSOLETE /* Issue #380 Kill this code! But leave in src, just in case! */
if ( nodeIsBODY( node ) && DescendantOf( element, TidyTag_HEAD )) if ( nodeIsBODY( node ) && DescendantOf( element, TidyTag_HEAD ))
{ {
/* If we're in the HEAD, close it before proceeding. /* If we're in the HEAD, close it before proceeding.
This is an extremely rare occurance, but has been observed. This is an extremely rare occurance, but has been observed.
****************************************************************
Issue #380 - This can cause an INFINITE loop!
This code was added to SF CVS Tidy
revision 1.121 by lpassey, Wed Jul 28 18:08:06 2004 UTC
****************************************************************
*/ */
TY_(UngetToken)( doc ); TY_(UngetToken)( doc );
break; break;
} }
#endif /* #if OBSOLETE */
if ( nodeIsHTML(node) || nodeIsHEAD(node) || nodeIsBODY(node) ) if ( nodeIsHTML(node) || nodeIsHEAD(node) || nodeIsBODY(node) )
{ {

View file

@ -1034,10 +1034,11 @@ static void PPrintText( TidyDocImpl* doc, uint mode, uint indent,
ix = IncrWS( ix, end, indent, ixWS ); ix = IncrWS( ix, end, indent, ixWS );
} }
else if (( c == '&' ) && (TY_(HTMLVersion)(doc) == HT50) && else if (( c == '&' ) && (TY_(HTMLVersion)(doc) == HT50) &&
(((ix + 1) == end) || (((ix + 1) < end) && (isspace(doc->lexer->lexbuf[ix+1])))) ) (((ix + 1) == end) || (((ix + 1) < end) && (isspace(doc->lexer->lexbuf[ix+1] & 0xff)))) )
{ {
/*\ /*\
* Issue #207 - This is an unambiguous ampersand need not be 'quoted' in HTML5 * Issue #207 - This is an unambiguous ampersand need not be 'quoted' in HTML5
* Issue #379 - Ensure only 0 to 255 passed to 'isspace' to avoid debug assert
\*/ \*/
PPrintChar( doc, c, (mode | CDATA) ); PPrintChar( doc, c, (mode | CDATA) );
} }
@ -1866,8 +1867,11 @@ static int TextEndsWithNewline(Lexer *lexer, Node *node, uint mode )
if ( (mode & (CDATA|COMMENT)) && TY_(nodeIsText)(node) && node->end > node->start ) if ( (mode & (CDATA|COMMENT)) && TY_(nodeIsText)(node) && node->end > node->start )
{ {
uint ch, ix = node->end - 1; uint ch, ix = node->end - 1;
/* Skip non-newline whitespace. */ /*\
while ( ix >= node->start && (ch = (lexer->lexbuf[ix] & 0xff)) * Skip non-newline whitespace.
* Issue #379 - Only if ix is GT start can it be decremented!
\*/
while ( ix > node->start && (ch = (lexer->lexbuf[ix] & 0xff))
&& ( ch == ' ' || ch == '\t' || ch == '\r' ) ) && ( ch == ' ' || ch == '\t' || ch == '\r' ) )
--ix; --ix;

View file

@ -1,2 +1,2 @@
5.1.45 5.1.45-Exp3
2016.03.04 2016.03.18