Skip to content

do not allow .. to walk up out of a Windows root - #319

Open
lazerg wants to merge 2 commits into
isaacs:mainfrom
lazerg:fix/dotdot-windows-root
Open

do not allow .. to walk up out of a Windows root#319
lazerg wants to merge 2 commits into
isaacs:mainfrom
lazerg:fix/dotdot-windows-root

Conversation

@lazerg

@lazerg lazerg commented Aug 23, 2026

Copy link
Copy Markdown

On Windows a .. in a pattern walks straight out of the root, so C:/../x collapses to x and //srv/share/../x turns into //srv/x. The guard from 7953af1 sits in levelTwoFileOptimize, which only runs on the file being matched, so the pattern side (firstPhasePreProcess at level 2, levelOneOptimize at level 1) was never guarded, and UNC roots weren't covered anywhere.

isWindowsRoot() now does that check in all three .. loops, and a .. landing on a root is dropped rather than consuming the root. Level 1 is the default, so this changes default behavior on Windows too.

Fixes #318

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.

optimizationLevel 2 lets .. erase the Windows drive root and UNC share from patterns

1 participant