1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

html: Process data before switching encoding

This reduces the amount of data to convert and avoids issues with EOF
detection.

Also reset EOF flag after switching encoding as a precaution.
This commit is contained in:
Nick Wellnhofer 2025-03-07 21:15:20 +01:00
parent 38f475072a
commit 5237d90fae

View File

@ -2768,6 +2768,9 @@ htmlParseData(htmlParserCtxtPtr ctxt, htmlAsciiMask mask,
if ((input->flags & XML_INPUT_HAS_ENCODING) == 0) {
xmlChar * guess;
if (in > chunk)
goto next_chunk;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
guess = NULL;
#else
@ -2781,6 +2784,7 @@ htmlParseData(htmlParserCtxtPtr ctxt, htmlAsciiMask mask,
}
input->flags |= XML_INPUT_HAS_ENCODING;
eof = PARSER_PROGRESSIVE(ctxt);
goto restart;
}
@ -3312,6 +3316,7 @@ htmlParseCharData(htmlParserCtxtPtr ctxt, int partial) {
}
input->flags |= XML_INPUT_HAS_ENCODING;
eof = PARSER_PROGRESSIVE(ctxt);
goto restart;
}