1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

html: Fix EOF handling in start tags

This commit is contained in:
Nick Wellnhofer
2024-09-11 15:06:55 +02:00
parent b19d353970
commit 27752f75ca

View File

@ -2784,7 +2784,7 @@ htmlFindEntityPrefix(const xmlChar *string, size_t slen, int isAttr,
*/ */
static xmlChar * static xmlChar *
htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) { htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, int stop) {
xmlChar *buffer = NULL; xmlChar *buffer = NULL;
int buffer_size = 0; int buffer_size = 0;
int maxLength = (ctxt->options & XML_PARSE_HUGE) ? int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
@ -2807,7 +2807,8 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
* Ok loop until we reach one of the ending chars * Ok loop until we reach one of the ending chars
*/ */
while ((PARSER_STOPPED(ctxt) == 0) && while ((PARSER_STOPPED(ctxt) == 0) &&
(CUR != 0) && (CUR != stop)) { (ctxt->input->cur < ctxt->input->end) &&
((stop == 0) || (CUR != stop))) {
if ((stop == 0) && (CUR == '>')) break; if ((stop == 0) && (CUR == '>')) break;
if ((stop == 0) && (IS_WS_HTML(CUR))) break; if ((stop == 0) && (IS_WS_HTML(CUR))) break;
@ -3758,7 +3759,7 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
* (S Attribute)* S? * (S Attribute)* S?
*/ */
SKIP_BLANKS; SKIP_BLANKS;
while ((CUR != 0) && while ((ctxt->input->cur < ctxt->input->end) &&
(CUR != '>') && (CUR != '>') &&
((CUR != '/') || (NXT(1) != '>')) && ((CUR != '/') || (NXT(1) != '>')) &&
(PARSER_STOPPED(ctxt) == 0)) { (PARSER_STOPPED(ctxt) == 0)) {
@ -3830,6 +3831,11 @@ failed:
SKIP_BLANKS; SKIP_BLANKS;
} }
if (ctxt->input->cur >= ctxt->input->end) {
discardtag = 1;
goto done;
}
/* /*
* Handle specific association to the META tag * Handle specific association to the META tag
*/ */
@ -3854,6 +3860,7 @@ failed:
} }
} }
done:
if (atts != NULL) { if (atts != NULL) {
for (i = 1;i < nbatts;i += 2) { for (i = 1;i < nbatts;i += 2) {
if (atts[i] != NULL) if (atts[i] != NULL)