Bugzilla – Attachment 124375 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 exclamation signs in the query
Bug-28316-escape-exclamation-signs-in-the-query.patch (text/plain), 2.22 KB, created by
Martin Renvoize (ashimema)
on 2021-09-01 15:01:09 UTC
(
hide
)
Description:
Bug 28316: escape exclamation signs in the query
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-09-01 15:01:09 UTC
Size:
2.22 KB
patch
obsolete
>From cb0a8b0515ccaa06f6e7a86d7d5c5b400f08e480 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Fri, 18 Jun 2021 10:44:56 +0300 >Subject: [PATCH] Bug 28316: escape exclamation signs in the query > >Currently having exclamation sign at the end of the query makes ES >search fail, and when you try to search for a book that has exclamation >sign in the tittle (something like "Words! words") won't show results >correctly as it tries to negate everything that is after exclamation >sign, making it impossible to search for books that have in in the title > >This patch escapes exclamation signs if it's at the end of the query or >has a space after it, resolving both of the issues listed above. > >To reproduce: >1) with ES enabled, search for the book with title that contains >exclamation sight at the end, like "book!", this search should result > in error. >2) do another search, but this time find/prepare beforehand book with a >title that has exclamation sign with a space after it, >e.g "exclamation! sign", it shouldn't find it as ES treats everything >after that exclamation sign as negation. >2) apply the patch. >3) perform searches from the steep one and two again. >Search from step one should no longer fail, while search from the step >two should find that book. > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 3 +++ > 1 file changed, 3 insertions(+) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index 14bf0486a9..b1d22f2bd9 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -951,6 +951,9 @@ sub _clean_search_term { > # and correctly ignore unevenly backslashed: > $term =~ s/((?<!\\)(?:[\\]{2})*:[^:\s]+(?<!\\)(?:[\\]{2})*)(?=:)/$1\\/g; > >+ # screen all exclamation signs that either are the last symbol or have white space after them >+ $term =~ s/(?:[\s\\]*!\s*)+(\s|$)/$1/g; >+ > # screen all brackets with backslash > $term =~ s/(?<!\\)(?:[\\]{2})*([\{\}\[\]])$lookahead/\\$1/g; > return $term; >-- >2.20.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