test: test: add null-byte escape test cases for '#' handling#473
Merged
alexander-akait merged 1 commit intowebpack:mainfrom Feb 26, 2026
Merged
test: test: add null-byte escape test cases for '#' handling#473alexander-akait merged 1 commit intowebpack:mainfrom
alexander-akait merged 1 commit intowebpack:mainfrom
Conversation
Document the \0# escape mechanism in parseIdentifier — callers must escape '#' in filesystem paths as '\0#' before passing to the resolver. Unescaped '#' always starts a URL fragment. Covers: - \0# in path unescaped to '#' (no fragment produced) - \0# dir + real fragment at end - multiple \0# escapes, then a real fragment - \0# with both query and fragment - unescaped '#' still treated as fragment start (regression guard) - Windows paths with \0# null-byte escape Ref: webpack/webpack#16819
alexander-akait
approved these changes
Feb 26, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #473 +/- ##
=======================================
Coverage 93.41% 93.41%
=======================================
Files 49 49
Lines 2384 2384
Branches 717 717
=======================================
Hits 2227 2227
Misses 128 128
Partials 29 29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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.
Problem
When a project lives in a directory containing
#(e.g./home/user/f#/webpack),webpack-dev-server fails to resolve modules because
#is treated as a URL fragmentseparator.
Ref: webpack/webpack#16819
Root Cause
The bug is not in
parseIdentifier. The\0#null-byte escape is the designedmechanism to embed a literal
#in a filesystem path. The actual fix belongsupstream in the code that constructs request strings from real filesystem paths so,
it must escape
#as\0#before passing to the resolver.Changes
Added test cases to test/identifier.test.js documenting the
\0#escape mechanism:\0#in path → unescaped to#, no fragment produced\0#dir + real fragment at end\0#escapes + real fragment\0#with both query and fragment#still treated as fragment start (regression guard)\0#escapeNo production code was changed.
Test Results
All 653 tests pass ✅