From 1836bde7b62d0932268b28a6e4f20060e32e70d3 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Mon, 4 Feb 2013 17:48:58 +0100 Subject: [PATCH] Bug 9554: single quote in didyoumean When using "url" or "uri" template toolkit filters, I noticed that double quotes are escaped (%22), but not single quotes. This causes sometimes a problem when URL is written in JavaScript code, in a string delimited by single quotes. This patch corrects by using double quotes for js strings. Also, adds a test for "didyoumean" feature : when feature is not activated, do not add corresponding javascript. Test plan : - activate OpacHighlightedWords syspref - activate "didyoumean" feature for OPAC - perform a search begining with a single quote (ie "'sport") => look for javascript errors (you may use firebug) Signed-off-by: Kyle M Hall --- .../prog/en/modules/opac-results-grouped.tt | 4 +- .../opac-tmpl/prog/en/modules/opac-results.tt | 24 +++++++++++-------- .../opac-tmpl/prog/en/modules/svc/suggestion.tt | 6 ++-- 3 files changed, 19 insertions(+), 15 deletions(-) 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 a461800..d17a906 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 @@ -16,8 +16,8 @@ var q_array = new Array(); // will hold the search terms, if possible $(document).ready(function(){ [% IF ( OpacHighlightedWords ) %] - $('a.title').each(function() { - $(this).attr('href', $(this).attr('href') + '&query_desc=[% query_desc | url %]'); + $("a.title").each(function() { + $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc |url %]"); }); [% END %] 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 30682c4..ece7d2b 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -104,8 +104,8 @@ function highlightOn() { [% END %] $(document).ready(function(){ [% IF ( OpacHighlightedWords ) %] - $('a.title').each(function() { - $(this).attr('href', $(this).attr('href') + '&query_desc=[% query_desc | url %]'); + $("a.title").each(function() { + $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc |url %]"); }); [% END %] @@ -303,12 +303,16 @@ $(document).ready(function(){ [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %] - $('#didyoumean').load('/cgi-bin/koha/svc/suggestion?render=stub&q=[% querystring | uri %]', +[% IF ( DidYouMean ) %] + $("#didyoumean").load("/cgi-bin/koha/svc/suggestion?render=stub&q=[% querystring |uri %]", function() { - $('.searchsuggestion').parent().parent().css({ - 'border-color': '#F4ECBE', - 'background-color': '#FFFBEA'}); - } ); + $(".searchsuggestion").parent().parent().css({ + "border-color": "#F4ECBE", + "background-color": "#FFFBEA" + }); + }); +[% END %] + }); //]]> @@ -325,7 +329,7 @@ $(document).ready(function(){
[% IF ( DidYouMean ) %] -
Not what you expected? Check for suggestions
+
Not what you expected? Check for suggestions
[% END %]
[% INCLUDE 'page-numbers.inc' %]
[% IF ( koha_spsuggest ) %] @@ -607,8 +611,8 @@ $(document).ready(function(){ [% END %] [% END %] - - + + [% IF ( SEARCH_RESULT.rating_total ) > 0 %]   ([% SEARCH_RESULT.rating_total %] votes) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/svc/suggestion.tt b/koha-tmpl/opac-tmpl/prog/en/modules/svc/suggestion.tt index 1bc77ba..7960445 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/svc/suggestion.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/svc/suggestion.tt @@ -14,13 +14,13 @@ [% END %] [% IF suggestions && suggestions.size %]
- Did you mean: + Did you mean: [% FOREACH suggestion IN suggestions %] - [% suggestion.label %] + [% suggestion.label |html %] [% END %]
[% ELSE %] - Sorry, no suggestions. + Sorry, no suggestions. [% END %] [% IF (render=='standalone') %]
-- 1.7.2.5