Bug 35943 - SQL reports groups/subgroups whose name contains regexp special characters break table filtering
Summary: SQL reports groups/subgroups whose name contains regexp special characters br...
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Julian Maurice
QA Contact: Kyle M Hall
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-30 14:12 UTC by Julian Maurice
Modified: 2024-05-28 15:48 UTC (History)
4 users (show)

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


Attachments
Bug 35943: Fix group/subgroup filtering of saved reports (3.80 KB, patch)
2024-01-30 14:47 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 35943: Fix group/subgroup filtering of saved reports (3.85 KB, patch)
2024-02-06 18:04 UTC, David Nind
Details | Diff | Splinter Review
Bug 35943: Fix group/subgroup filtering of saved reports (3.90 KB, patch)
2024-03-22 10:59 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2024-01-30 14:12:21 UTC
Groups and subgroups filtering uses regular expressions. The filter looks like "^" + name + "$"
The problem is that the special characters in group/subgroup name are not properly escaped, which means that if a name contains "+", "*", or any other regexp special characters, filtering will probably fail.

Another (minor) problem is that we use the name to filter instead of the code. So if we have two groups or two subgroups with the same name, it will show reports from both groups/subgroups. There is no reason to have groups/subgroups with the same name, but it is possible (whereas it's not possible to have different groups/subgroups with the same code), so this should be fixed too.
Comment 1 Julian Maurice 2024-01-30 14:47:17 UTC
Created attachment 161645 [details] [review]
Bug 35943: Fix group/subgroup filtering of saved reports

Use code instead of name for filtering and escape regexp special
characters.

This patch also disables datatables' smart filtering as it is not
recommended to use with regexp filtering

https://datatables.net/reference/api/search()

Test plan:
1. Create a report in a group named "Foo + Bar" and in a subgroup named
   "Baz + Quux"
2. Create other reports in group "Foo + Bar" but in other subgroups, as
   well as in other groups. This is useful to see the effect of
   filtering
3. Go to the saved reports page and verify that navigating between tabs
   have the desired result. Same for the subgroup select
Comment 2 David Nind 2024-02-06 18:04:09 UTC
Created attachment 161793 [details] [review]
Bug 35943: Fix group/subgroup filtering of saved reports

Use code instead of name for filtering and escape regexp special
characters.

This patch also disables datatables' smart filtering as it is not
recommended to use with regexp filtering

https://datatables.net/reference/api/search()

Test plan:
1. Create a report in a group named "Foo + Bar" and in a subgroup named
   "Baz + Quux"
2. Create other reports in group "Foo + Bar" but in other subgroups, as
   well as in other groups. This is useful to see the effect of
   filtering
3. Go to the saved reports page and verify that navigating between tabs
   have the desired result. Same for the subgroup select

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Kyle M Hall 2024-03-22 10:59:37 UTC
Created attachment 163694 [details] [review]
Bug 35943: Fix group/subgroup filtering of saved reports

Use code instead of name for filtering and escape regexp special
characters.

This patch also disables datatables' smart filtering as it is not
recommended to use with regexp filtering

https://datatables.net/reference/api/search()

Test plan:
1. Create a report in a group named "Foo + Bar" and in a subgroup named
   "Baz + Quux"
2. Create other reports in group "Foo + Bar" but in other subgroups, as
   well as in other groups. This is useful to see the effect of
   filtering
3. Go to the saved reports page and verify that navigating between tabs
   have the desired result. Same for the subgroup select

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Katrin Fischer 2024-03-22 11:28:35 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 5 Fridolin Somers 2024-05-22 14:22:57 UTC
Pushed to 23.11.x for 23.11.06
Comment 6 Lucas Gass 2024-05-28 15:48:37 UTC
Backported to 23.05.x for upcoming 23.05.12