Repository navigation
Conversation
Characters above U+00FF passed the range check and were cut to their low byte when pushed into the Uint8Array, so %"Ł" parsed as "A" and %"Ā" as a NUL. RFC 9651 section 4.2.10 says to fail on anything that is not VCHAR or SP. TextDecoder also drops a leading BOM by default, so a value starting with U+FEFF lost that character on parse and did not round-trip.
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.
parseDisplayStringchecks each character with<= 0x1for0x7f..0xff, so anything above U+00FF passes. It is then pushed into aUint8Array, which keeps only the low byte:RFC 9651 section 4.2.10 says to fail if a character is not in VCHAR or SP, so these should throw, like
"Ł"already does for plain strings. The check is now<= 0x1f || >= 0x7f.Second, smaller thing in the same function:
TextDecoderdrops a leading BOM by default, so a value that starts with U+FEFF loses it on parse and does not round-trip:Added
ignoreBOM: trueso the character is kept.Tests are in a new
test/parser-tests.js; all 3 fail on main and pass with the change. I also ran 100k random field values through the old and new parser: the only results that changed are values starting with%ef%bb%bf.Note:
make unit-testhas 4 failures on main too, from round-tie-to-even cases that were added toserialisation-tests/number.jsonin the httpwg suite after the last CI run. They are not touched here.