Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: strip standalone "." directory path #2711

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taeruh
Copy link

@taeruh taeruh commented Jan 11, 2024

The problem is that in Ignore::matched, the perfix "./" is stripped from files. In Ignore::matched_ignore, the directory path is then stripped from file paths. Now imagine we have a hidden file "./.foo" and pass "." as the search path. "./.foo" gets first stripped to ".foo" and then it would have been stripped to "foo".

I am not completely sure though whether this is the best way to fix it. One could also check earlier whether the directory path is "." and then change it to "./". I don't know which is the best way regarding performance; the current fix is just at the place where it breaks. What do you think?

The implications of this problem (at least the ones I noticed) are that when grepping (including hidden files and passing . as search directory) in a subdirectory a/b of a, and b has a hidden file .foo, which is ignored in a ignore file in a, the contents of .foo are shown.
I put in https://github.com/taeruh/debug_file_paths a minimal debugging example to show that.

Issue #829 is similar, but I am not sure about how much it is related.

The problem is that in Ignore::matched, the perfix "./" is stripped from
files. In Ignore::matched_ignore, the directory path is then stripped
from file paths. Now imagine we have a hidden file "./.foo" and pass "."
as the search path. "./.foo" gets first stripped to ".foo" and then it
would have been stripped to "foo".
tmccombs added a commit to tmccombs/fd that referenced this pull request Mar 14, 2024
tmccombs added a commit to tmccombs/fd that referenced this pull request Mar 14, 2024
sharkdp pushed a commit to sharkdp/fd that referenced this pull request Apr 30, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request May 6, 2024
v10.0.0

Features
- Add `dir` as an alias to `directory` when using `-t` \ `--type`, see #1460 and #1464 (@Ato2207).
- Add support for @%s date format in time filters similar to GNU date (seconds since Unix epoch for --older/--newer), see #1493 (@nabellows)
- Breaking: No longer automatically ignore `.git` when using `--hidden` with vcs ignore enabled. This reverts the change in v9.0.0. While this feature
  was often useful, it also broke some existing workflows, and there wasn't a good way to opt out of it. And there isn't really a good way for us to add
  a way to opt out of it. And you can easily get similar behavior by adding `.git/` to your global fdignore file.
    See #1457.

Bugfixes
- Respect NO_COLOR environment variable with `--list-details` option. (#1455)
- Fix bug that would cause hidden files to be included despite gitignore rules
  if search path is "." (#1461, BurntSushi/ripgrep#2711).
- aarch64 builds now use 64k page sizes with jemalloc. This fixes issues on some systems, such as ARM Macs that
  have a larger system page size than the system that the binary was built on. (#1547)
- Address [CVE-2024-24576](https://blog.rust-lang.org/2024/04/09/cve-2024-24576.html), by increasing minimum rust version.

Changes
- Minimum supported rust version is now 1.77.2

On pkgsrc this has been reverted as CVE-2024-24576 only affects Windows.
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.

None yet

1 participant