fix: validate low surrogate in encodeString#92
Draft
deepview-autofix wants to merge 1 commit intoanonrig:mainfrom
Draft
fix: validate low surrogate in encodeString#92deepview-autofix wants to merge 1 commit intoanonrig:mainfrom
deepview-autofix wants to merge 1 commit intoanonrig:mainfrom
Conversation
When a high surrogate (0xD800–0xDBFF) was not followed by a valid low surrogate, the encoder still combined the next code unit into a supplementary code point, producing invalid UTF-8 percent-encoded output and swallowing the following character. Validate that the second code unit is a low surrogate (0xDC00–0xDFFF) and throw "URI malformed" otherwise, matching the behaviour for an unpaired trailing high surrogate. Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com> Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com> Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
Contributor
|
Unlike #91, this also affects Node.js, so compat might be more important here Converted to draft for now Upd: let's wait for this to be discussed on nodejs/node#62814 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #92 +/- ##
==========================================
+ Coverage 68.97% 69.38% +0.41%
==========================================
Files 7 7
Lines 448 454 +6
Branches 72 73 +1
==========================================
+ Hits 309 315 +6
Misses 136 136
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
When a high surrogate (0xD800–0xDBFF) was not followed by a valid low surrogate, the encoder still combined the next code unit into a supplementary code point, producing invalid UTF-8 percent-encoded output and swallowing the following character. Validate that the second code unit is a low surrogate (0xDC00–0xDFFF) and throw "URI malformed" otherwise, matching the behaviour for an unpaired trailing high surrogate.