core: Refactor XML unescape and error handling #22756
Open
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.
While working on #21107, I discovered that quick_xml errors do not map 1:1 with Flash errors, so make_xml_error needs to be refactored (and all the code adapted). Doing it in that PR would be too hectic (quick-xml has had major breaking changes), so I'm submitting this separately. This PR also does some minor refactors and implements a FIXME.
No functional changes intended, everything should map to the exact same error code as before. There's quite a lot of xml tests, so if they all pass, we can be reasonably sure this does not break anything.
Context for the decoder usage removal:
The decoder doesn't actually do anything special for us, since we don't use the encoding feature. So there's no need to pass it around.
https://docs.rs/quick-xml/latest/quick_xml/encoding/struct.Decoder.html
It can be seen here that without the encoding feature, std::str::from_utf8 is all the decoder does.
https://docs.rs/quick-xml/latest/src/quick_xml/encoding.rs.html#121-129