fix: escape carriage return as in builder output - #16
Open
gaoflow wants to merge 1 commit into
Open
Conversation
…tput A raw CR emitted in text or attribute values is folded to LF by any conforming XML parser (XML 1.0 2.11), so a build -> parse round trip silently turned "\r" into "\n". Add CR to the default entity table so it is preserved; LF and TAB stay verbatim.
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.
The builder emits a raw carriage return in text and attribute values. A raw CR is normalized to LF by any conforming XML parser (XML 1.0 §2.11), so the CR is silently lost on the next parse — including through fast-xml-parser's own round trip:
Fix: add CR to the default entity table so it serializes as
, which is how CR has to be represented in XML. LF and TAB are left verbatim — they survive a round trip; CR is the only character that gets folded.A sweep of U+0001–U+00FF in both text and attribute positions confirms CR is the only value that fails the round trip. The added tests cover the escaped output, the round trip, and that LF/TAB stay unescaped.