Bugzilla – Attachment 11658 Details for
Bug 8646
Certain search terms cause browser "script taking too long" error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8646 - prevent the highlighter from going infinite loop
Bug-8646---prevent-the-highlighter-from-going-infi.patch (text/plain), 3.73 KB, created by
Jonathan Druart
on 2012-08-17 12:38:49 UTC
(
hide
)
Description:
Bug 8646 - prevent the highlighter from going infinite loop
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2012-08-17 12:38:49 UTC
Size:
3.73 KB
patch
obsolete
>From f79f27be3ff674c899e23ec5d5867fd3ce893fcf Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Thu, 16 Aug 2012 16:57:29 +0200 >Subject: [PATCH] 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> >--- > .../prog/en/modules/catalogue/results.tt | 5 +++++ > .../prog/en/modules/opac-results-grouped.tt | 5 +++++ > .../opac-tmpl/prog/en/modules/opac-results.tt | 5 +++++ > 3 files changed, 15 insertions(+), 0 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 1ebc862..390732f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -96,6 +96,11 @@ $(".addtocart").show(); > toHighlight = $("p,span.results_summary,a.title"); > var query_desc = "[% query_desc |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"; > q_array = query_desc.split(" "); >+ // ensure that we don't have "" at the end of the array, which can >+ // break the highlighter >+ while (q_array.length > 0 && q_array[q_array.length-1] == "") { >+ q_array = q_array.splice(0,-1); >+ } > highlightOn(); > $("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;}); > $("#highlight_toggle_off").show().click(function() {highlightOff();}); >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >index 99c31bd..f8755ad 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results-grouped.tt >@@ -58,6 +58,11 @@ $(document).ready(function(){ > [% IF ( query_desc ) %] > var query_desc = "[% query_desc |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"; > q_array = query_desc.split(" "); >+ // ensure that we don't have "" at the end of the array, which can >+ // break the highlighter >+ while (q_array.length > 0 && q_array[q_array.length-1] == "") { >+ q_array = q_array.splice(0,-1); >+ } > highlightOn(); > $("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;}); > $("#highlight_toggle_off").show().click(function() {highlightOff();}); >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 67b1686..a2751cb 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -203,6 +203,11 @@ $(document).ready(function(){ > > [% IF ( query_desc ) %][% IF ( OpacHighlightedWords ) %]var query_desc = "[% query_desc |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"; > q_array = query_desc.split(" "); >+ // ensure that we don't have "" at the end of the array, which can >+ // break the highlighter >+ while (q_array.length > 0 && q_array[q_array.length-1] == "") { >+ q_array = q_array.splice(0,-1); >+ } > highlightOn(); > $("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;}); > $("#highlight_toggle_off").show().click(function() {highlightOff();});[% END %][% END %] >-- >1.7.7.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8646
:
11641
| 11658