rust: don't escape spaces in regex
authorSpencer Baugh <sbaugh@janestreet.com>
Wed, 02 Aug 2023 09:59:49 -0400
changeset 50859 2b4bcdc948e7
parent 50858 df6dfad5009a
child 50860 f50e71fdfcb4
rust: don't escape spaces in regex Spaces are not in fact a regex special character, and escaping them is not correct.
rust/hg-core/src/filepatterns.rs
--- a/rust/hg-core/src/filepatterns.rs	Wed Aug 02 10:09:23 2023 -0400
+++ b/rust/hg-core/src/filepatterns.rs	Wed Aug 02 09:59:49 2023 -0400
@@ -24,7 +24,7 @@
 lazy_static! {
     static ref RE_ESCAPE: Vec<Vec<u8>> = {
         let mut v: Vec<Vec<u8>> = (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 @@
         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()
         );
     }