Bug 30393 - datatables wrapper should handle searching for %, _ and \
Summary: datatables wrapper should handle searching for %, _ and \
Status: Pushed to stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 30055 30394 31565
  Show dependency treegraph
 
Reported: 2022-03-29 10:55 UTC by Tomás Cohen Arazi
Modified: 2022-09-14 13:54 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.05


Attachments
Bug 30393: Make datatables wrapper handle searching for % and _ (1.70 KB, patch)
2022-03-30 09:30 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30393: Make datatables wrapper handle searching for %, _, \ (1.66 KB, patch)
2022-03-30 10:13 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30393: Make datatables wrapper handle searching for %, _, \ (1.81 KB, patch)
2022-03-30 10:29 UTC, Séverine Queune
Details | Diff | Splinter Review
Bug 30393: Make datatables wrapper handle searching for %, _, \ (1.88 KB, patch)
2022-03-30 11:52 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 30393: Make datatables wrapper handle searching for %, _, \ (1.94 KB, patch)
2022-03-30 12:37 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2022-03-29 10:55:32 UTC
This characters have special meanings in LIKE queries in MariaDB/MySQL and should be escaped correctly. [1]

[1] https://dev.mysql.com/doc/refman/8.0/en/string-literals.html
Comment 1 Tomás Cohen Arazi 2022-03-30 09:30:57 UTC
Created attachment 132544 [details] [review]
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>
Comment 2 Tomás Cohen Arazi 2022-03-30 10:13:08 UTC
Created attachment 132551 [details] [review]
Bug 30393: Make datatables wrapper handle searching for %, _, \

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 _'
   - 'London \'
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>
Comment 3 Séverine Queune 2022-03-30 10:29:55 UTC
Created attachment 132553 [details] [review]
Bug 30393: Make datatables wrapper handle searching for %, _, \

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 _'
   - 'London \'
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>
Signed-off-by: Séverine Queune <severine.queune@bulac.fr>
Comment 4 Séverine Queune 2022-03-30 10:31:10 UTC
Works nice, this is an happy sign-off ! :D
Comment 5 Jonathan Druart 2022-03-30 11:52:24 UTC
Created attachment 132561 [details] [review]
Bug 30393: Make datatables wrapper handle searching for %, _, \

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 _'
   - 'London \'
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>
Signed-off-by: Séverine Queune <severine.queune@bulac.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Martin Renvoize 2022-03-30 12:37:57 UTC
Created attachment 132597 [details] [review]
Bug 30393: Make datatables wrapper handle searching for %, _, \

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 _'
   - 'London \'
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>
Signed-off-by: Séverine Queune <severine.queune@bulac.fr>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize 2022-03-30 12:38:29 UTC
Just adding another QA stamp as I was also working through testing this one.
Comment 8 Fridolin Somers 2022-04-04 07:49:23 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 9 Kyle M Hall 2022-04-08 12:25:57 UTC
Pushed to 21.11.x for 21.11.05