From ec22cd07fd7cf7c9c331768fbcefc234c659257d Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Mon, 14 Jun 2021 16:38:51 +0300 Subject: [PATCH] Bug 28316: avoid messing up regexes in the search queries This patch ensures that the behavior with QueryRegexEscapeOptions set to values other than "Escape" still will works as expected. It does so by storing the contents of regexes before escaping special characters and then restores the contents of regexes back to how it was before, ensuring that searching with regex is possible. Signed-off-by: Alex Buckley --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 8176760bdc..f10992c873 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -938,6 +938,19 @@ sub _clean_search_term { } $term = $self->_query_regex_escape_process($term); + # save all regex contents away before escaping brackets: + my @saved_regexes; + my $rgx_i = 0; + while( + $term =~ s@( + (?