From ed7c26ff9f3dd249af041f4f2bfffbf62cac6b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 24 Apr 2023 16:39:19 +0200 Subject: [PATCH] push: Use bytes Regex to fix regex construction Due to a new error detected in the regex crate. --- crates/ruma-common/src/push/condition.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ruma-common/src/push/condition.rs b/crates/ruma-common/src/push/condition.rs index 7f1a6e5c..42ccc5fb 100644 --- a/crates/ruma-common/src/push/condition.rs +++ b/crates/ruma-common/src/push/condition.rs @@ -1,7 +1,7 @@ use std::{collections::BTreeMap, ops::RangeBounds, str::FromStr}; use js_int::{Int, UInt}; -use regex::Regex; +use regex::bytes::Regex; #[cfg(feature = "unstable-msc3931")] use ruma_macros::StringEnum; use serde::{Deserialize, Serialize}; @@ -392,7 +392,7 @@ impl StrExt for str { // The word characters in ASCII compatible mode (with the `-u` flag) match the // definition in the spec: any character not in the set `[A-Za-z0-9_]`. let regex = format!(r"(?-u:^|\W|\b){}(?-u:\b|\W|$)", chunks.concat()); - Regex::new(®ex).ok().filter(|re| re.is_match(self)).is_some() + Regex::new(®ex).ok().filter(|re| re.is_match(self.as_bytes())).is_some() } else { match self.find(pattern) { Some(start) => {