Skip to content

Commit

Permalink
Bug 10956 - Series of OPAC searches can cause a browser crash
Browse files Browse the repository at this point in the history
This patch fixes the issue for bootstrap. It was earlier fixed for the prog theme.

Solution: Prevent  jQuery.fn.highlight = function(pat) to be called with empty pat
by skipping empty values in highlight loop.

To test:
Without patch, do a search as in comment #1 odr #3
Result: Endless loop (Script not responding)

Appply patch:
No endless loop, page displays OK

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
To reproduce you need to search a string with 2 spaces.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
I didn't manage to reproduce the problem, but I couldn't find
any regression either trying multiple searches.
Trusting Marc's and Jonathan's testing.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
  • Loading branch information
veronch authored and tomascohen committed Nov 25, 2014
1 parent b4c0eb4 commit c087027
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
Expand Up @@ -1354,13 +1354,15 @@
function highlightOn() {
var x;
for (x in q_array) {
q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1");
q_array[x] = q_array[x].toLowerCase();
var myStopwords = "[% Koha.Preference('NotHighlightedWords') %]".toLowerCase().split('|');
if( $.inArray(q_array[x], myStopwords) == -1 ) {
$(".title").highlight(q_array[x]);
$(".author").highlight(q_array[x]);
$(".results_summary").highlight(q_array[x]);
if ( q_array[x].length > 0 ) {
q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1");
q_array[x] = q_array[x].toLowerCase();
var myStopwords = "[% Koha.Preference('NotHighlightedWords') %]".toLowerCase().split('|');
if( $.inArray(q_array[x], myStopwords) == -1 ) {
$(".title").highlight(q_array[x]);
$(".author").highlight(q_array[x]);
$(".results_summary").highlight(q_array[x]);
}
}
}
$(".highlight_toggle").toggle();
Expand Down

0 comments on commit c087027

Please sign in to comment.