Bugzilla – Attachment 140757 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: Fix datatables searching escape for exact search
Bug-31565-Fix-datatables-searching-escape-for-exac.patch (text/plain), 2.60 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-09-19 18:09:37 UTC
(
hide
)
Description:
Bug 31565: Fix datatables searching escape for exact search
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-09-19 18:09:37 UTC
Size:
2.60 KB
patch
obsolete
>From 41d0daaff8ac04d58fd44f3a35c4c7be2197a9fe 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: 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> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index f6b079c794..197c2e09fd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -578,8 +578,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > > function build_query(col, value){ > >- // escape SQL special characters >- value = value.replace(/(\%|\_|\\)/g, "\\$1" ); >+ // escape SQL special character \ >+ value = value.replace(/(\\)/g, "\\$1" ); > > var parts = []; > var attributes = col.data.split(':'); >@@ -590,6 +590,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.34.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 31565
:
140636
|
140637
|
140709
|
140753
|
140754
|
140755
|
140756
| 140757 |
140758
|
140978
|
140984
|
142861