Some search terms, particularly those with space characters and similar non-alpha things at the end, can cause the javascript highlighter to go into an infinite loop which causes an error in the browser. Search queries such as: http://koha-intra/cgi-bin/koha/catalogue/search.pl?kw=idx&q=ti:book%20 reproduce this. Curiously, the OPAC is unaffected by this, however it has similar code processes that mean it may be possible for this to happen there too.
Created attachment 11641 [details] [review] Bug 8646 - prevent the highlighter from going infinite loop On certain search queries, for example http://koha-intra/cgi-bin/koha/catalogue/search.pl?kw=idx&q=ti:book%20 the highlighter starts going into an infinite loop until the browser decides to kill it. This patch prevents the bad input going to the highlighter. It also includes the fix on the OPAC, even though the issue doesn't come up there. Better to be safe...
Created attachment 11658 [details] [review] Bug 8646 - prevent the highlighter from going infinite loop On certain search queries, for example http://koha-intra/cgi-bin/koha/catalogue/search.pl?kw=idx&q=ti:book%20 the highlighter starts going into an infinite loop until the browser decides to kill it. This patch prevents the bad input going to the highlighter. It also includes the fix on the OPAC, even though the issue doesn't come up there. Better to be safe... Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Works as expected. I fixed that (in BibLibre repo) with: function highlightOn() { var x; for (x in q_array) { - $("p").highlight(q_array[x]); + if ( q_array[x].length > 0 ) { + $("p").highlight(q_array[x]); + } } $(".highlight_toggle").toggle(); } But your patch looks good too.
Drops empty strings are the end of the array in order to prevent infinite loops. Template only change in JS. Marking Passed QA.
Patch pushed to master
Pushed to 3.8.x will be in 3.8.5
*** Bug 8736 has been marked as a duplicate of this bug. ***