fix: normalize --full-path matches for parent search paths (fixes #1513)#2002
Open
leno23 wants to merge 2 commits into
Open
fix: normalize --full-path matches for parent search paths (fixes #1513)#2002leno23 wants to merge 2 commits into
leno23 wants to merge 2 commits into
Conversation
When searching from a subdirectory with a relative root like `..`, --full-path compared unnormalized paths (e.g. cwd/../foo) against absolute patterns. Normalize paths that contain `.` or `..` components. Fixes sharkdp#1513. Co-authored-by: Cursor <cursoragent@cursor.com>
21907dd to
2784f08
Compare
This comment was marked as low quality.
This comment was marked as low quality.
1 task
Windows CI failed because backslashes in the temp-dir path were interpreted as regex escapes. Build the pattern with regex::escape. Co-authored-by: Cursor <cursoragent@cursor.com>
This comment was marked as low quality.
This comment was marked as low quality.
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
Fixes #1513:
--full-pathmatching failed when the search path contained..(or.), because the match string was built as e.g./tmp/1/2/../foowithout normalization, while the pattern used the canonical/tmp/1/foo.Approach
When building the absolute path for
--full-pathmatching, normalize vianormpathonly if the relative entry path contains.or..components; otherwise keep the existing join behavior.Testing
test_full_path_normalizes_relative_search_pathcargo test full_path_normalizescargo clippy -- -D warningsNote
Similar fix was proposed in #1969 (closed without merge); happy to credit @lawrence3699 if maintainers prefer that attribution.
Made with Cursor