Skip to content

Treat unmatched double quotes as literal path characters - #211

Open
xianjianlf2 wants to merge 1 commit into
micromatch:masterfrom
xianjianlf2:fix/unmatched-double-quote
Open

xianjianlf2 wants to merge 1 commit into
micromatch:masterfrom
xianjianlf2:fix/unmatched-double-quote

Conversation

@xianjianlf2

Copy link
Copy Markdown

A literal unmatched double quote in a filename starts quoted mode and causes later glob tokens to be treated as literal text:

picomatch.isMatch('root/"dir/index.js', 'root/"dir/*.js'); // false before this fix

Enter quoted mode only when an unescaped closing quote exists. An unmatched quote stays literal, allowing the following * or ? to work. Paired quotes keep their existing quoting behavior, and escaped quotes do not count as closing delimiters.

This reproduces directly in picomatch 4.0.7 on macOS with Node 22.23.1. It also underlies fast-glob #494; the review of fast-glob #511 recommended addressing the matcher instead of a filesystem-layer workaround. This is a fresh implementation in the parser.

Validation: the new regression fails before the fix; npm test passes ESLint and all 1,999 tests. Regressions cover default options, disabled fast paths, keepQuotes, escaped closing quotes, and negative matches.

AI assistance: OpenAI Codex (GPT-6 Astra) investigated, implemented, tested, and prepared this PR at the account owner's request. This was an autonomous agent contribution; no independent human review is claimed.

Only enter quoted mode when an unescaped closing quote remains, so an unmatched quote does not disable following glob tokens.

Assisted-by: OpenAI Codex (GPT-6 Astra, autonomous)
Signed-off-by: MarkXian <mark-xian@foxmail.com>
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.

1 participant