Bugzilla – Attachment 132544 Details for
Bug 30393
datatables wrapper should handle searching for %, _ and \
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30393: Make datatables wrapper handle searching for % and _
Bug-30393-Make-datatables-wrapper-handle-searching.patch (text/plain), 1.70 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-03-30 09:30:57 UTC
(
hide
)
Description:
Bug 30393: Make datatables wrapper handle searching for % and _
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-03-30 09:30:57 UTC
Size:
1.70 KB
patch
obsolete
>From 80f3757898e06e4563d7afa18d370eb6d5fbbdf7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 30 Mar 2022 11:28:11 +0200 >Subject: [PATCH] Bug 30393: Make datatables wrapper handle searching for % and > _ > >This patch makes searching for '%' and '_' work by escaping those >symbols in the query before sending them to the API. > >To test: >1. Go to the cities page >2. Add two cities: > - 'Cordoba %' > - 'Buenos Aires _' >3. Use the column search on the name, alternating _ and % as the query >=> FAIL: Weird behavior >4. Apply this patch and reload >5. Repeat 3 >=> SUCCESS: Filtering works correctly! >6. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 8cddbc46fe..8309702e3c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -562,6 +562,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > for (var i=0;i<attributes.length;i++){ > var part = {}; > var attr = attributes[i]; >+ // escape SQL special characters >+ value = value.replace(/(\%|\_)/g, "\\$1" ); > let criteria = options.criteria; > if ( value.match(/^\^(.*)\$$/) ) { > value = value.replace(/^\^/, '').replace(/\$$/, ''); >-- >2.35.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 30393
:
132544
|
132551
|
132553
|
132561
|
132597