# HG changeset patch # User Spencer Baugh # Date 2023-08-02 13:59:49 # Node ID 2b4bcdc948e78220e8e23425c964d74c3f0c8f23 # Parent df6dfad5009a700155ba5ec25b3b10b149308a3a rust: don't escape spaces in regex Spaces are not in fact a regex special character, and escaping them is not correct. diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -24,7 +24,7 @@ use std::vec::Vec; lazy_static! { static ref RE_ESCAPE: Vec> = { let mut v: Vec> = (0..=255).map(|byte| vec![byte]).collect(); - let to_escape = b"()[]{}?*+-|^$\\.&~# \t\n\r\x0b\x0c"; + let to_escape = b"()[]{}?*+-|^$\\.&~#\t\n\r\x0b\x0c"; for byte in to_escape { v[*byte as usize].insert(0, b'\\'); } @@ -641,8 +641,8 @@ mod tests { assert_eq!(escape_pattern(untouched), untouched.to_vec()); // All escape codes assert_eq!( - escape_pattern(br#"()[]{}?*+-|^$\\.&~# \t\n\r\v\f"#), - br#"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\ \\t\\n\\r\\v\\f"# + escape_pattern(br#"()[]{}?*+-|^$\\.&~#\t\n\r\v\f"#), + br#"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\\t\\n\\r\\v\\f"# .to_vec() ); }