Bugzilla – Attachment 121976 Details for
Bug 28316
Fix ES crashes related to various punctuation characters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28316: escape brackets in the search query
Bug-28316-escape-brackets-in-the-search-query.patch (text/plain), 1.71 KB, created by
Peter Vashchuk
on 2021-06-15 07:47:00 UTC
(
hide
)
Description:
Bug 28316: escape brackets in the search query
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2021-06-15 07:47:00 UTC
Size:
1.71 KB
patch
obsolete
>From dc2fc242cb06f994f1719fbe9810d9f68e908577 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >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. >--- > 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 3a80b37797..6d26adff4c 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/((?<!\\)(?:[\\]{2})*:[^:\s]+(?<!\\)(?:[\\]{2})*)(?=:)/$1\\/g; > >+ >+ # screen all brackets with backslash >+ $term =~ s/(?<!\\)(?:[\\]{2})*([\{\}\[\]])$lookahead/\\$1/g; > return $term; > } > >-- >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 28316
:
121435
|
121443
|
121561
|
121562
|
121751
|
121752
|
121753
|
121754
|
121755
|
121756
|
121837
|
121838
|
121839
|
121840
|
121841
|
121842
|
121975
|
121976
|
121977
|
121978
|
121979
|
121980
|
122103
|
122104
|
122105
|
122106
|
122107
|
122108
|
122201
|
122202
|
122203
|
122204
|
122205
|
122206
|
122801
|
122802
|
122803
|
122804
|
122805
|
122806
|
123601
|
123602
|
123603
|
123604
|
123605
|
123606
|
124372
|
124373
|
124374
|
124375
|
124376
|
124377
|
124378
|
124560
|
124561
|
124562
|
124563
|
124564
|
124565
|
124566
|
124709
|
124710
|
124711
|
124712
|
124713
|
124714
|
124715