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.
Key Changes:
Fixes #361
What problem does this code solve?
Bug fix for XML Escaping that was included in a2d3b59 as part of a fix supporting unicode entities (i.e.


which maps to a new line character)The original fix was causing XML string to be unescaped twice which was also causing the bug as mentioned in #361.
Risks
Low/none. This is a bug fix to correct incorrect parsing of XML entities.
Changes to the API?
One new package level method was added to
XMLTokener
that handles all valid XML entity unescaping.Will this require a new release?
Yes. The bug affects processing XML documents only, however, the bug prevents valid XML files from being read.
Should the documentation be updated?
No
Does it break the unit tests?
No. All unit tests should pass. New unit tests were added in order to test the changes and ensure that entities are only unencoded once. See stleary/JSON-Java-unit-test#79
Was any code refactored in this commit?
Yes. The actual implementation for the unescapeing was moved from the
XML
class to theXMLTokener
class.XMLTokener
was already unescaping named entities (i.e.<
to<
and&
to&
) however it was not converting unicode entities back to their codepoints (i.e"
to"
or4
to4
). To compensate for that I originally created theXML.unescape
method and incorrectly injected it into the XML processing.This PR corrects that by moving all the entity handling into the
XMLTokener
class and removing theunescape
injection that I placed into the processing last time.Review status
APPROVED Starting 3 day window for comments.