Bugzilla – Attachment 121839 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.06 KB, created by
Peter Vashchuk
on 2021-06-11 13:24:12 UTC
(
hide
)
Description:
Bug 28316: escape exclamation signs in the query
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2021-06-11 13:24:12 UTC
Size:
2.06 KB
patch
obsolete
>From 73d50509b6fc99842dfda5666458bb07ea4a7ab4 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Fri, 11 Jun 2021 14:37:19 +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. >--- > 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 000edc26d7..c32dd31ea2 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -946,6 +946,9 @@ sub _clean_search_term { > $term =~ s/(:+)(\s+)$lookahead/$2/g; > $term =~ s/(\s+)(:+)$lookahead/$1/g; > >+ # screen all exclamation signs that either are the last symbol or have white space after them >+ $term =~ s/((?<!\\)(?:[\\]{2})*(!(\s|$)))/\\$1/g; >+ > # screen all followups for colons after first colon, > # and correctly ignore unevenly backslashed: > $term =~ s/((?<!\\)(?:[\\]{2})*:[^:\s]+(?<!\\)(?:[\\]{2})*)(?=:)/$1\\/g; >-- >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