The general filter above the item table in /catalogue/detail.pl breaks if you try to search something begining with ( or [ The "processing" popup never fades. The console displays: Uncaught SyntaxError: Invalid regular expression: /^(/i: Unterminated group (at datatables_25.0600018.js:556:47)
Actually I'm not sure this should be considered as a bug. DataTable actually support regular expression for filtering the values. For example, for a record I've set 3 items, 1 fiction, 1 non-fiction, and 1 "reference". I can have both "fiction" and "non-fiction" to appear by using this string in the search input of the table : ".*(iction)" Knowing this I'm not sure we can say parenthesis "breaks" the filter. However I was not able to properly escape the parenthesis or brackets https://www.threesl.com/blog/special-characters-regular-expressions-escape/
Created attachment 187523 [details] [review] Bug 40907: Add a Cypress test
Created attachment 187524 [details] [review] Bug 40907: Prevent DT crash when searching with regex metachars We should remove the regex metacharacters from the string or JS code will raise an error and the query won't be generated, leading to the DT neverending loading problem. Test plan: Go to http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=4 In the global "Search" of the items table, search using a regex metacharacters in order to form a broken regex (eg. '[') => Without this patch there is a JS error in the console "Uncaught SyntaxError: unterminated character class" and you get the "Processing" that never ends => With this patch applied the search succeeds.
It is not known by librarian that we should use regex syntax here, so we consider the present behavior as a bug ;-)
Created attachment 187534 [details] [review] Bug 40907: Prevent DT crash when searching with regex metachars We should remove the regex metacharacters from the string or JS code will raise an error and the query won't be generated, leading to the DT neverending loading problem. Test plan: Go to http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=4 In the global "Search" of the items table, search using a regex metacharacters in order to form a broken regex (eg. '[') => Without this patch there is a JS error in the console "Uncaught SyntaxError: unterminated character class" and you get the "Processing" that never ends => With this patch applied the search succeeds. Signed-off-by: Mathieu <mathsabypro@gmail.com>
Created attachment 187535 [details] [review] Bug 40907: Add a Cypress test Signed-off-by: Mathieu <mathsabypro@gmail.com>
Created attachment 187536 [details] [review] Bug 40907: Prevent DT crash when searching with regex metachars We should remove the regex metacharacters from the string or JS code will raise an error and the query won't be generated, leading to the DT neverending loading problem. Test plan: Go to http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=4 In the global "Search" of the items table, search using a regex metacharacters in order to form a broken regex (eg. '[') => Without this patch there is a JS error in the console "Uncaught SyntaxError: unterminated character class" and you get the "Processing" that never ends => With this patch applied the search succeeds. Signed-off-by: Mathieu <mathsabypro@gmail.com>
Thank you Jonathan. I tested on a sandbox : no more error in the console, and I was able to find callnumber such as "[a" or "(a"
Created attachment 187599 [details] [review] Bug 40907: Add a Cypress test Signed-off-by: Mathieu <mathsabypro@gmail.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Created attachment 187600 [details] [review] Bug 40907: Prevent DT crash when searching with regex metachars We should remove the regex metacharacters from the string or JS code will raise an error and the query won't be generated, leading to the DT neverending loading problem. Test plan: Go to http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=4 In the global "Search" of the items table, search using a regex metacharacters in order to form a broken regex (eg. '[') => Without this patch there is a JS error in the console "Uncaught SyntaxError: unterminated character class" and you get the "Processing" that never ends => With this patch applied the search succeeds. Signed-off-by: Mathieu <mathsabypro@gmail.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Created attachment 188022 [details] [review] Bug 40907: Add a Cypress test Signed-off-by: Mathieu <mathsabypro@gmail.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 188023 [details] [review] Bug 40907: Prevent DT crash when searching with regex metachars We should remove the regex metacharacters from the string or JS code will raise an error and the query won't be generated, leading to the DT neverending loading problem. Test plan: Go to http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=4 In the global "Search" of the items table, search using a regex metacharacters in order to form a broken regex (eg. '[') => Without this patch there is a JS error in the console "Uncaught SyntaxError: unterminated character class" and you get the "Processing" that never ends => With this patch applied the search succeeds. Signed-off-by: Mathieu <mathsabypro@gmail.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Nice work everyone! Pushed to main for 25.11
Nice work everyone! Pushed to 25.05.x
Pushed to 24.11.x for 24.11.11