allow zero LI in UL when html5. fix for #396

This commit is contained in:
Raphael Ackermann 2016-04-08 23:08:56 +02:00
parent fdf2169ebf
commit b704a4d0d4
4 changed files with 20 additions and 5 deletions

View file

@ -328,7 +328,6 @@ static Bool CanPrune( TidyDocImpl* doc, Node *element )
if (nodeIsDD(element))
return no;
return yes;
}
@ -2514,7 +2513,14 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
continue;
}
if ( !nodeIsLI(node) )
if ( nodeIsLI(node) || TY_(IsHTML5Mode)(doc))
{
/* node is <LI>
Issue #396 - A <ul> can have Zero or more li elements
*/
TY_(InsertNodeAtEnd)(list,node);
}
else
{
TY_(UngetToken)( doc );
@ -2567,9 +2573,6 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode))
TY_(InsertNodeAtEnd)(list,node);
}
}
else
/* node is <LI> */
TY_(InsertNodeAtEnd)(list,node);
ParseTag( doc, node, IgnoreWhitespace);
}

View file

@ -780,6 +780,12 @@ void TY_(AdjustTags)( TidyDocImpl *doc )
}
}
Bool TY_(IsHTML5Mode)( TidyDocImpl *doc )
{
return doc->HTML5Mode;
}
/*\
* Issue #285
* Reset the table to default HTML5 mode.
@ -809,6 +815,7 @@ void TY_(ResetTags)( TidyDocImpl *doc )
#if ELEMENT_HASH_LOOKUP
tagsEmptyHash( doc, tags ); /* not sure this is really required, but to be sure */
#endif
doc->HTML5Mode = yes; /* set HTML5 mode */
}
void TY_(FreeTags)( TidyDocImpl* doc )
@ -823,6 +830,8 @@ void TY_(FreeTags)( TidyDocImpl* doc )
/* get rid of dangling tag references */
TidyClearMemory( tags, sizeof(TidyTagImpl) );
doc->HTML5Mode = no; /* reset html5 mode == legacy html4 mode */
}

View file

@ -88,6 +88,7 @@ void TY_(InitTags)( TidyDocImpl* doc );
void TY_(FreeTags)( TidyDocImpl* doc );
void TY_(AdjustTags)( TidyDocImpl *doc ); /* if NOT HTML5 DOCTYPE, fall back to HTML4 legacy mode */
void TY_(ResetTags)( TidyDocImpl *doc ); /* set table to HTML5 mode */
Bool TY_(IsHTML5Mode)( TidyDocImpl *doc );
/* Parser methods for tags */

View file

@ -76,6 +76,8 @@ struct _TidyDocImpl
uint badChars; /* for bad char encodings */
uint badForm; /* bit field, for badly placed form tags, or other format errors */
Bool HTML5Mode; /* current mode is html5 */
/* Memory allocator */
TidyAllocator* allocator;