fix: XML::Reader#attribute_hash returns nil on error #2715
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.
What problem is this PR intended to solve?
Reader#attribute_hash
does not behave the same wayReader#attribute_nodes
behaved when parse errors are encountered.For callers of
Reader#attributes
this restores the behavior from v1.13.7 before #2602.See also the related change in #2714 which will land in v1.14.0 that raises a
SyntaxError
instead of returningnil
.Have you included adequate test coverage?
Yes, coverage added.
Does this change affect the behavior of either the C or the Java implementations?
The C and Java parsers differ in when they detect a syntax error in this case. libxml2 indicates an error when we try to expand a start tag that does not have a matching end tag, but xerces will defer the error until later. The tests reflect that difference.