fix: normalized Windows drive letter must be exactly two code points#1156
Merged
anonrig merged 1 commit intoJul 3, 2026
Merged
Conversation
Member
|
running tests |
`is_normalized_windows_drive_letter` accepted any input of length >= 2 that
started with `<ASCII alpha>:`. Per the URL standard a normalized Windows drive
letter is a Windows drive letter, i.e. exactly two code points. The loose check
made `shorten_path` (file scheme) treat longer first segments such as `c:x` or
`u:p@h` as drive letters and refuse to pop them on `..`:
parse("file:c:x/..") -> "file:///c:x/" (expected "file:///")
parse("file:u:p@h/..") -> "file:///u:p@h/" (expected "file:///")
A genuine drive letter (`file:c:/..` -> "file:///c:/") is unaffected. Verified
against the full WHATWG url web-platform-tests (urltestdata, 0 regressions).
a096666 to
1e7308d
Compare
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1156 +/- ##
==========================================
- Coverage 59.80% 59.78% -0.02%
==========================================
Files 37 37
Lines 6127 6127
Branches 2978 2978
==========================================
- Hits 3664 3663 -1
Misses 618 618
- Partials 1845 1846 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
anonrig
approved these changes
Jul 3, 2026
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.
is_normalized_windows_drive_letteraccepted any input of length>= 2beginning with<ASCII alpha>:. Per the URL Standard a normalized Windows drive letter is a Windows drive letter, which is two code points, so the check should require exactly two.The loose length let shorten a url's path treat a longer first segment that merely starts with
<alpha>:as a drive letter and skip popping it on..:A real drive letter is unaffected:
file:c:/..still yieldsfile:///c:/.The fix changes
>= 2to== 2. All three call sites (shorten_pathand the base-path drive-letter check inparser.cpp) pass a single path segment that should match only an exact drive letter, so the tighter check is correct for each.Verified against the full WHATWG URL web-platform-tests
urltestdata(no regressions) and added a regression test.