From 00c41f9d95a6b0fb359f7a4874b9acc138510db8 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Tue, 13 Jul 2021 12:13:03 +0300 Subject: [PATCH] Bug 28316: escape brackets in the search query This patch screens square and curly brackets which have no special language meaning. To reproduce: 1) using ES, search for the book with title that contains square and/or curly brackets, like "book [second edition]", which will result in error. 2) apply the patch. 3) search for that book again, ensure that it works now. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Alex Buckley Signed-off-by: Martin Renvoize Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 952b5a6a469460e926905d6582688dd903988aad) Signed-off-by: Victor Grousset/tuxayo --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index f12639edc4..5f340c1ec4 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -930,7 +930,6 @@ sub _clean_search_term { $term =~ s/=/:/g; $term = $self->_convert_index_strings_freeform($term); - $term =~ s/[{}]/"/g; # Remove unbalanced quotes my $unquoted = $term; @@ -952,6 +951,8 @@ sub _clean_search_term { # and correctly ignore unevenly backslashed: $term =~ s/((?