fix: preserve carriage returns inside CDATA#835
Open
viraatdas wants to merge 2 commits into
Open
Conversation
The 'should normalize carriage returns outside CDATA' test passed on master both with and without the source change, so it guarded no behavior. Keep the 'should preserve carriage returns in CDATA' test, which exercises the actual fix.
Member
|
Thanks for the PR. new line and carriage return were being removed in starting to simplify regex if I remember correctly. But now most of the code is not using regex. So I'm not sure if we need to remove them at all. Will check once |
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 #512
Problem
parseXmlnormalizes line endings withxmlData.replace(/\r\n?/g, "\n")at the top ofOrderedObjParser, which also rewrites\rinside CDATA sections. CDATA content must be preserved byte for byte, so a literal carriage return inside CDATA comes back as\n.Fix
Replace the blanket normalization with a CDATA-aware pass that skips CDATA sections (and tags/comments) and normalizes line endings only outside CDATA. Carriage returns inside CDATA are now preserved; everything else still normalizes as before. Edits
src/xmlparser/OrderedObjParser.js(source), not the generated bundle.Tests
Added a regression test ("should preserve carriage returns in CDATA") that fails before the change and passes after, plus a guard test for normalization outside CDATA. Full jasmine suite passes.