Bugzilla – Attachment 142861 Details for
Bug 31565
Patron search filter by category code with special character returns no results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31565: [22.05.x] Fix datatables searching escape for exact search
Bug-31565-2205x-Fix-datatables-searching-escape-fo.patch (text/plain), 3.38 KB, created by
Nick Clemens (kidclamp)
on 2022-11-01 11:36:53 UTC
(
hide
)
Description:
Bug 31565: [22.05.x] Fix datatables searching escape for exact search
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-11-01 11:36:53 UTC
Size:
3.38 KB
patch
obsolete
>From 7e2b4aa17ea5e02200844e654d576dbf573d3b15 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Wed, 14 Sep 2022 14:34:48 +0000 >Subject: [PATCH] Bug 31565: [22.05.x] Fix datatables searching escape for > exact search > >To test: >1. Add a new patron category with categorycode 'TEST_CAT' >2. Add a patron to category 'TEST_CAT' >3. Go to Patrons search view >4. Under "Search for patron" filters, filter by category you created at step 1 >5. Click Search >6. Observe no results >7. Apply this patch and reload >8. Repeat 3-5 >9. Observe expected result > >Double check tests from Bug 30393 still work as expected: > >10. Go to the cities page >11. Add two cities: > - 'Cordoba %' > - 'Buenos Aires _' > - 'London \' >12. Use the column search on the name, alternating _, \ and % as the query >=> SUCCESS: Filtering works correctly! > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Bug 31565: Escape datatables MySQL special characters only in LIKE queries > >Escaping \ yields no results when performing exact search in datatables. >This patch adds MySQL special character escaping only to LIKE searches. > >To test: >1. Add following categorycode 'TEST\CAT' by SQL >insert into categories (categorycode,description) values ('TEST\\CAT', 'TEST\\CAT'); >2. Add a patron into TEST\CAT category >3. Go to patron search >4. Limit search by category TEST\CAT >5. Observe no results >6. Apply patch >7. Refresh patron search page >8. Limit search by category TEST\CAT >9. Observe Koha redirecting you to patron you chose in step 2 > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Bug 31565: (QA follow-up) Remove support for _ as wildcard in -like queries > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 21dfe52636..74cb2cf0ef 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -578,9 +578,6 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > > function build_query(col, value){ > >- // escape SQL special characters >- value = value.replace(/(\%|\_|\\)/g, "\\$1" ); >- > var parts = []; > var attributes = col.data.split(':'); > for (var i=0;i<attributes.length;i++){ >@@ -590,6 +587,9 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > if ( value.match(/^\^(.*)\$$/) ) { > value = value.replace(/^\^/, '').replace(/\$$/, ''); > criteria = "exact"; >+ } else { >+ // escape SQL LIKE special characters % and _ >+ value = value.replace(/(\%|\\)/g, "\\$1"); > } > part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact' > ? value >-- >2.30.2
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 31565
:
140636
|
140637
|
140709
|
140753
|
140754
|
140755
|
140756
|
140757
|
140758
|
140978
|
140984
| 142861