fix: preserve root path '/' in _abs_path_to_file normalization#213
Closed
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Closed
fix: preserve root path '/' in _abs_path_to_file normalization#213Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Conversation
The trailing slash stripping regex s{/$}{} incorrectly converted bare
'/' to an empty string, causing paths like '/foo/..' (which resolve to
'/') and bare '/' itself to fall through to the CWD-based relative path
handler instead of returning '/'.
Fix: use a lookbehind (?<=.) to require at least one character before
the trailing slash, so '/' alone is never stripped.
Added tests for '/', '/there/..', '/a/b/../../c', and integration
tests verifying _mock_stat resolves /. and /.. paths correctly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Contributor
Author
|
Superseded by #215 which provides a comprehensive component-based path canonicalization fix. |
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.
Summary
_abs_path_to_filethat incorrectly converted bare/to empty string/foo/..(resolving to/) and bare/itself were falling through to the CWD-based relative path handler instead of returning/(?<=.)to prevent stripping/when it's the only characterContext
Found while investigating #108. The
.case (/there/.) already resolved correctly, but the..case (/there/..→/) was broken because the normalization loop would reduce the path to/, then strip that final slash to an empty string.Test plan
_abs_path_to_fileunit tests: bare/,/there/..,/a/b/../../c-dand_mock_statresolve/parent/.and/parent/child/..correctly🤖 Generated with Claude Code