From 348c0a531ab9d3e9f48eed9abafbaec1d973a213 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Mon, 14 Jun 2021 16:39:13 +0300 Subject: [PATCH] Bug 28316: escape brackets in the search query This patch screens square and curly brackets which have no special language meaning, while keeping ranges as they are, allowing ES to search for biblios with titles that contain square and curly brackets and at the same time allows the use of range searches ([1990 TO 2000]). 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. 4) additionally perform a search using range, for example: "[1999 TO 2020]", ensure that it works correctly too. Signed-off-by: Victor Grousset/tuxayo --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 6346656ddb..f5cb9bfc62 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,9 @@ sub _clean_search_term { # and correctly ignore unevenly backslashed: $term =~ s/((?