Skip to content

Escape regexp metacharacters when converting globs to regexps - #174

Open
Wilfred wants to merge 1 commit into
masterfrom
claude/fix-glob-regexp-metachars
Open

Escape regexp metacharacters when converting globs to regexps#174
Wilfred wants to merge 1 commit into
masterfrom
claude/fix-glob-regexp-metachars

Conversation

@Wilfred

@Wilfred Wilfred commented Aug 16, 2026

Copy link
Copy Markdown
Owner

deadgrep--glob-regexp copied literal glob characters into the elisp regexp verbatim, so a glob containing regexp metacharacters matched the wrong files: *.h++ produced ^.*\.h++$, which matches foo.h and foo.hh but not foo.h++. Since this function backs deadgrep--relevant-file-type, it could make deadgrep suggest the wrong default file type.

Literal characters are now passed through regexp-quote. Existing glob metacharacter handling (*, ?, ., [...]) is unchanged and still covered by the existing tests; new tests cover the metacharacter case.

(Current ripgrep's --type-list happens to contain no globs with regexp metacharacters, so this is mostly a latent bug — but older rg versions and user-defined types can hit it.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01MwUBSSJnCtCeoqJEA3xH48

deadgrep--glob-regexp copied literal glob characters into the elisp
regexp verbatim, so a glob containing regexp metacharacters matched
the wrong files: *.h++ matched foo.h and foo.hh but not foo.h++.
This could make deadgrep--relevant-file-type suggest the wrong
default file type.

Quote literal characters with regexp-quote.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MwUBSSJnCtCeoqJEA3xH48
@Wilfred
Wilfred force-pushed the claude/fix-glob-regexp-metachars branch from b1ac999 to 52d1dcf Compare August 18, 2026 21:31
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 59.86%. remained the same — claude/fix-glob-regexp-metachars into master

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.

3 participants