Bugzilla – Attachment 120971 Details for
Bug 28326
If ElasticSearch enable is not possible to edit or save records with ' ES reserved charset' like []
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28326: Escape special characters in title when searching for analytics
Bug-28326-Escape-special-characters-in-title-when-.patch (text/plain), 2.11 KB, created by
Nick Clemens (kidclamp)
on 2021-05-14 13:35:09 UTC
(
hide
)
Description:
Bug 28326: Escape special characters in title when searching for analytics
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-05-14 13:35:09 UTC
Size:
2.11 KB
patch
obsolete
>From 05f880608dc118fac8c021566d580e70214998d2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 14 May 2021 13:30:46 +0000 >Subject: [PATCH] Bug 28326: Escape special characters in title when searching > for analytics > >Bug 26313 introduced a search for analytics, which is great, but it started >sending titles to ES. This, unfrotunately, caused problems where the title >contained reserved ES characters. > >As these searches should always be literl title searches, we should escape all the ES >characters before the search. > >We should not make this a standard, however, as then it prevents using the characters for advanced ES >searching > >To test: >1 - Have ES setup and running and swtich SearchEngine syspref to 'Elasticsearch' >2 - Edit a record and add some reserved ES characters to the title > https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html > e.g. De [Crasi] Aristophea. >3 - You get an error on the detail page loading >4 - Apply patch >5 - Reload >6 - The page successfully loads >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + > catalogue/detail.pl | 3 +++ > 2 files changed, 4 insertions(+) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index eed466049b..4de2deb83f 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -951,6 +951,7 @@ sub _clean_search_term { > > $term = $self->_query_regex_escape_process($term); > >+ > return $term; > } > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 8d06f0da51..43bd6831c1 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -128,6 +128,9 @@ if ( $xslfile ) { > { index => $Koha::SearchEngine::BIBLIOS_INDEX } > ); > my $cleaned_title = $biblio->title; >+ $cleaned_title =~ s/(\+|\-|\=|\&\&|\|\||\!|\(|\)|\{|\}|\[|\]|\^|\"|\~|\*|\?|\:|\\|\/)/\\$1/g; >+ $cleaned_title =~ s/(<|>)/ /g; >+ > $cleaned_title =~ tr|/||; > my $query = > ( C4::Context->preference('UseControlNumber') and $record->field('001') ) >-- >2.11.0
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 28326
:
120971
|
121000
|
121035
|
121436