Skip to content

Commit

Permalink
tests: Use normal XML_Parse in test_suspend_resume_internal_entity
Browse files Browse the repository at this point in the history
When the parser is suspended, _XML_Parse_SINGLE_BYTES() will return
early. At that point, there could be some amount of bytes that haven't
been fed into Expat at all yet. This leaves us with an incomplete
document.

Furthermore, the last internal XML_Parse() call with isFinal=XML_TRUE
will not have happened, so the parser will not know that no more input
is to be expected. This is what allowed the test to pass when it was
originally changed to use SINGLE_BYTES.

With the new partial token heuristic, the lack of a final parse call
means that we don't even reach the "Ho" text, and fail the test.

The simplest solution is to go back to using XML_Parse() in this test.
Another option would be to let SINGLE_BYTES expose how far it got in
its loop, allowing for later continuation, but it doesn't seem worth the
extra complexity.
  • Loading branch information
Snild-Sony committed Jan 29, 2024
1 parent 3484383 commit 60dffa1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion expat/tests/basic_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3625,7 +3625,9 @@ START_TEST(test_suspend_resume_internal_entity) {
XML_SetStartElementHandler(g_parser, start_element_suspender);
XML_SetCharacterDataHandler(g_parser, accumulate_characters);
XML_SetUserData(g_parser, &storage);
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
// can't use SINGLE_BYTES here, because it'll return early on suspension, and
// we won't know exactly how much input we actually managed to give Expat.
if (XML_Parse(g_parser, text, (int)strlen(text), XML_TRUE)
!= XML_STATUS_SUSPENDED)
xml_failure(g_parser);
CharData_CheckXMLChars(&storage, XCS(""));
Expand Down

0 comments on commit 60dffa1

Please sign in to comment.