mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 03:11:32 +00:00
Escape backslashes in fuzzy_search (#4462)
* Escape backslashes in fuzzy_search * Update utils.rs
This commit is contained in:
parent
ae62ef2b7e
commit
d79502dff3
1 changed files with 5 additions and 1 deletions
|
@ -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}%")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue