Repository navigation
Conversation
An xsd:sequence with maxOccurs=unbounded whose elements are all optional kept looping when the next xml element didn't belong to it, because each iteration consumed nothing and max_occurs_iter goes up to 2**31. Break out once an iteration doesn't consume anything so the parent can deal with the element (XMLParseError in strict mode, ignored otherwise). Fixes mvantellingen#1457
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1457
When a sequence has maxOccurs="unbounded" and all its children are optional, an element that doesn't belong to it made Sequence.parse_xmlelements spin forever, since every pass consumed nothing and the loop only stops when the deque is empty or after 2**31 passes. I made it stop as soon as a pass doesn't consume anything, which is what Choice already does.
Notes
I reproduced it offline with the EUR-Lex WSDL and the envelope from the issue. With the fix the response now fails fast with
XMLParseError: Unexpected element ... MANIFESTATION_OFFICIAL-JOURNAL_PART_PAGES_TOTALin strict mode, which matches the comment that the response doesn't validate against their XSD, and withstrict=Falseit parses fine. For non-repeating sequences nothing changes, they still return the one (possibly empty) item like before.