From 1e4ca489310ce90456ffdff211c172eb0819afc8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 4 Jul 2022 15:19:27 -0300 Subject: [PATCH] Bug 31106: Make clean_search_term escape double quotes We noticed that several characters will break Zebra queries. So search terms need to be quoted for things to work. In this context, double quotes inside search terms are problematic because double quotes are what we use for quoting strings. This patch makes the clean_search_term method escape double quotes. To test: 1. Apply the unit tests patch 2. Run: $ kshell k$ prove t/Koha/SearchEngine/Zebra/QueryBuilder.t => FAIL: It doesn't work as it should! 3. Apply this patch 4. Repeat 2 => SUCCESS: It does the job! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 24bb15785dd7f176c1ffe2bf8ae5e8a05cc0707a) Signed-off-by: Lucas Gass (cherry picked from commit 2e063b708d29095de6462f063ae4d092f22c386f) Signed-off-by: Arthur Suzuki --- Koha/SearchEngine/Zebra/QueryBuilder.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/SearchEngine/Zebra/QueryBuilder.pm b/Koha/SearchEngine/Zebra/QueryBuilder.pm index b0011d09a9..8b8d3473e7 100644 --- a/Koha/SearchEngine/Zebra/QueryBuilder.pm +++ b/Koha/SearchEngine/Zebra/QueryBuilder.pm @@ -127,6 +127,8 @@ sub build_authorities_query_compat { sub clean_search_term { my ( $self, $term ) = @_; + $term =~ s/"/\\"/g; + return $term; } -- 2.39.5