Remove leading whitespace from the XML under test #41027
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This test was originally written with the intention of asserting that
a runtime error related to XXE will be raised by the parser. However,
because initial whitespace is present before the doctype,
XmlMini_NokogiriSAX::HashBuilder has been raising an unrelated error
in this test.
Related to #41015
Other Information
Using Nokogiri v1.10.10, the error being raised without this change
is:
but with this change we see the expected exception from the libxml2
SAX parser:
Using Nokogiri v1.11.0, in which error handling is broken (see
sparklemotion/nokogiri#2168), without this change we see an exception
being raised by HashBuilder because
characters
is called beforestart_element
and so the content hash isn't initialized (seeThe error being raised with this change is:
which is not the error we want (because of
sparklemotion/nokogiri#2168), but the test still passes.
Using Nokogiri with the fix from sparklemotion/nokogiri#2169, the
error being raised without this change is:
but with this change will be:
and we're back to the expected behavior.