push: Use bytes Regex to fix regex construction

Due to a new error detected in the regex crate.
This commit is contained in:
Kévin Commaille 2023-04-24 16:39:19 +02:00 committed by Kévin Commaille
parent 0143bd9b9f
commit ed7c26ff9f

View File

@ -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(&regex).ok().filter(|re| re.is_match(self)).is_some()
Regex::new(&regex).ok().filter(|re| re.is_match(self.as_bytes())).is_some()
} else {
match self.find(pattern) {
Some(start) => {