From d79502dff3401e23dfb538edc73fbb3cbfe4d8d9 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Sun, 18 Feb 2024 07:12:56 -0700 Subject: [PATCH] Escape backslashes in fuzzy_search (#4462) * Escape backslashes in fuzzy_search * Update utils.rs --- crates/db_schema/src/utils.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index be551a160..213e0015e 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -236,7 +236,11 @@ impl LimitDsl for Commented { } pub fn fuzzy_search(q: &str) -> String { - let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%"); + let replaced = q + .replace('\\', "\\\\") + .replace('%', "\\%") + .replace('_', "\\_") + .replace(' ', "%"); format!("%{replaced}%") }