globset: add allow_unclosed_class toggle

When enabled, patterns like `[abc`, `[]`, `[!]` are treated as if the
opening `[` is just a literal. This is in contrast the default behavior,
which prioritizes better error messages, of returning a parse error.

Fixes #3127, Closes #3145
This commit is contained in:
mostafa
2025-09-12 22:53:35 +03:00
committed by Andrew Gallant
parent 556623684e
commit f596a5d875
4 changed files with 193 additions and 17 deletions

View File

@@ -1519,3 +1519,28 @@ rgtest!(r3108_files_without_match_quiet_exit, |dir: Dir, _: TestCommand| {
.stdout();
eqnice!("", got);
});
// See: https://github.com/BurntSushi/ripgrep/issues/3127
rgtest!(
r3127_gitignore_allow_unclosed_class,
|dir: Dir, mut cmd: TestCommand| {
dir.create_dir(".git");
dir.create(".gitignore", "[abc");
dir.create("[abc", "");
dir.create("test", "");
let got = cmd.args(&["--files"]).stdout();
eqnice!("test\n", got);
}
);
// See: https://github.com/BurntSushi/ripgrep/issues/3127
rgtest!(
r3127_glob_flag_not_allow_unclosed_class,
|dir: Dir, mut cmd: TestCommand| {
dir.create("[abc", "");
dir.create("test", "");
cmd.args(&["--files", "-g", "[abc"]).assert_err();
}
);