Bugzilla – Attachment 121273 Details for
Bug 28292
Searching with colon ":" in the end of query gives internal server error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28292: strip the colon when it ends the query
Bug-28292-strip-the-colon-when-it-ends-the-query.patch (text/plain), 2.50 KB, created by
Peter Vashchuk
on 2021-05-21 12:07:46 UTC
(
hide
)
Description:
Bug 28292: strip the colon when it ends the query
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2021-05-21 12:07:46 UTC
Size:
2.50 KB
patch
obsolete
>From 11b4f3622ea58445bec70a70fb2c06058625b62d Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Fri, 21 May 2021 15:06:45 +0300 >Subject: [PATCH] Bug 28292: strip the colon when it ends the query > >This patch adds additional regexp that strips the colon when it ends >the query to avoid the internal server error. Also this patch adds new >tests that check if colon gets removed from the very beginning and >the very end of the query. > >To reproduce: >1) Enable ES and try to search "test:", which should give the internal server error. >2) Apply the patch, perform the same search again. Make sure that it doesn't gives that same error. >3) Additionally run t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t test and ensure that all tests are successful. >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 ++-- > t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 8 +++++++- > 2 files changed, 9 insertions(+), 3 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index a39931ab0b..2c04ce221f 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -940,10 +940,10 @@ sub _clean_search_term { > } > > # Remove unquoted colons that have whitespace on either side of them >+ $term =~ s/^:\s*//; >+ $term =~ s/\s*:+$//; > $term =~ s/(:+)(\s+)$lookahead/$2/g; > $term =~ s/(\s+)(:+)$lookahead/$1/g; >- $term =~ s/^://; >- > $term = $self->_query_regex_escape_process($term); > > return $term; >diff --git a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >index b2ce6f4319..fbabda76c5 100755 >--- a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >+++ b/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t >@@ -187,7 +187,7 @@ subtest '_split_query() tests' => sub { > }; > > subtest '_clean_search_term() tests' => sub { >- plan tests => 12; >+ plan tests => 14; > > my $qb; > ok( >@@ -207,6 +207,12 @@ subtest '_clean_search_term() tests' => sub { > $res = $qb->_clean_search_term('"unbalanced "quotes"'); > is($res, ' unbalanced quotes ', 'unbalanced quotes removed'); > >+ $res = $qb->_clean_search_term(':test query'); >+ is($res, 'test query', 'colon at the start removed'); >+ >+ $res = $qb->_clean_search_term('test query:'); >+ is($res, 'test query', 'colon at the end removed'); >+ > $res = $qb->_clean_search_term('test : query'); > is($res, 'test query', 'dangling colon removed'); > >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28292
: 121273