Repository navigation
fix: preserve original metadata offsets for CRLF input - #911
Merged
amitguptagwl merged 1 commit intoNov 3, 2026
Merged
amitguptagwl merged 1 commit into
amitguptagwl merged 1 commit into
Conversation
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.
Purpose / Goal
Fixes #910.
With
captureMetaData: true, CRLF input currently produces offsets into the normalized string. Slicing the original input with those offsets therefore returns the wrong XML. For example, thevaluenode in<root>\r\n <value>42</value>\r\n</root>starts at 10 and ends at 27, but the parser reports 9 and 26.Keep normalizing line endings in parsed values, and translate captured start/end positions back to the original input. Record the collapsed CRLF positions only when metadata capture is enabled. Coverage includes declarations, processing instructions, attributes, comments, CDATA, stop nodes, unpaired tags, dropped siblings, and string/Buffer/Uint8Array input.
Type
Validation
npm test: 340 specs, 0 failures, 2 existing pending.git diff --checkpass.Performance
Ran
node benchmark/XmlParser.mjsbefore and after. Requests/sec (before → after): fxp v3 140393 → 133425; fxp 58385 → 58070; fxp preserve-order 68802 → 66858; xmlbuilder2 31260 → 30162; xml2js 31063 → 38879. These are shared-host Windows observations; the benchmark uses metadata capture disabled.Prepared with Codex assistance, automated tests, and independent agent review.