Escape backslashes in fuzzy_search (#4462)

* Escape backslashes in fuzzy_search

* Update utils.rs
This commit is contained in:
dullbananas 2024-02-18 07:12:56 -07:00 committed by GitHub
parent ae62ef2b7e
commit d79502dff3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -236,7 +236,11 @@ impl<T: LimitDsl> LimitDsl for Commented<T> {
}
pub fn fuzzy_search(q: &str) -> String {
let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%");
let replaced = q
.replace('\\', "\\\\")
.replace('%', "\\%")
.replace('_', "\\_")
.replace(' ', "%");
format!("%{replaced}%")
}