Filter globs: no backslash escapes on Windows

Query validation now matches platform::glob_match, where '\' is the path
separator on Windows rather than an escape.
This commit is contained in:
Andy Dixon
2026-10-08 20:10:18 +01:00
parent 9179281a94
commit b21bcedba0
+3 -3
View File
@@ -321,13 +321,13 @@ pub(super) fn name_match(v: &str) -> Expr {
/// Reports whether pattern is a well-formed glob (see /// Reports whether pattern is a well-formed glob (see
/// `platform::glob_match`): every `[` class is closed and non-empty, ranges /// `platform::glob_match`): every `[` class is closed and non-empty, ranges
/// have both ends, and no escape is dangling. /// have both ends, and (on Unix, where `\` escapes) no escape is dangling.
fn glob_ok(p: &[u8]) -> bool { fn glob_ok(p: &[u8]) -> bool {
// One possibly escaped character of a range; None if malformed. // One possibly escaped character of a range; None if malformed.
let esc = |mut i: usize| -> Option<usize> { let esc = |mut i: usize| -> Option<usize> {
match p.get(i)? { match p.get(i)? {
b'-' | b']' => return None, b'-' | b']' => return None,
b'\\' => { b'\\' if cfg!(unix) => {
i += 1; i += 1;
p.get(i)?; p.get(i)?;
} }
@@ -338,7 +338,7 @@ fn glob_ok(p: &[u8]) -> bool {
let mut i = 0; let mut i = 0;
while i < p.len() { while i < p.len() {
match p[i] { match p[i] {
b'\\' => { b'\\' if cfg!(unix) => {
if i + 1 >= p.len() { if i + 1 >= p.len() {
return false; return false;
} }