Repository navigation
Conversation
Keep escaped backslash pairs as exact repetitions instead of collapsing literal filenames. Route escape runs through the tokenizer while preserving unescape behavior and the pattern length limit. Refs mrmlnc/fast-glob#262.
Kenoia
marked this pull request as ready for review
October 7, 2026 12:55
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.
A POSIX filename containing two consecutive backslashes is missed by its correctly escaped pattern, while the same pattern incorrectly matches a filename containing only one backslash.
The fast parser and tokenizer both collapse consecutive escapes. Patterns containing escaped backslash pairs now use the tokenizer, which preserves each pair as one literal backslash. Longer runs compile to a fixed repetition, so a 65K-character pattern still has a compact regex. An odd final escape continues to escape the following glob character. Explicit
unescape: truebehavior is retained.The existing long-escape test is updated to expect 32,750 literal backslashes from 65,500 escape characters, and to reject the shorter filename. Its negation, invalid-regex and length-limit checks remain in place.
Related to mrmlnc/fast-glob#262, identified while investigating POSIX backslash filenames. This addresses the matcher behavior for consecutive literal backslashes; fast-glob's path conversion and task-base handling require separate work.
Validation on Arch Linux:
9fab7bf61913ea334c4203ed321c426cfde44a42and pass with this change.npm run lintandnpm run test:cipass, 2,008 tests; line coverage 95.7%, branch coverage 91.89%.unescape: trueacross fast/full parsing and Windows/POSIX options produce the same regex sources as the base.Native Windows and macOS runs and the other supported Node versions await the existing CI matrix.