Skip to content

fix: validate low surrogate in encodeString#92

Draft
deepview-autofix wants to merge 1 commit intoanonrig:mainfrom
deepview-autofix:deepview/d579234d5d
Draft

fix: validate low surrogate in encodeString#92
deepview-autofix wants to merge 1 commit intoanonrig:mainfrom
deepview-autofix:deepview/d579234d5d

Conversation

@deepview-autofix
Copy link
Copy Markdown
Contributor

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.

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>
@deepview-autofix deepview-autofix marked this pull request as draft April 19, 2026 00:58
@ChALkeR
Copy link
Copy Markdown
Contributor

ChALkeR commented Apr 19, 2026

Unlike #91, this also affects Node.js, so compat might be more important here
Investigating if the impl in Node.js makes any sense on this...

Converted to draft for now

Upd: let's wait for this to be discussed on nodejs/node#62814

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.38%. Comparing base (9dcbaf2) to head (3b224a2).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants