Bug 12071: improve generation of Z39.50 search links

This patch fixes two problems with the generation of
links to execute a Z39.50 search from the staff client
catalog and cataloguing search results page.

First, if using URI::Escape 3.30 or earlier, performing a simple search
with a double quote (e.g., "histoire algerie"), the Javascript is broken
in results page because of :

function GetZ3950Terms(){
  var strQuery="&frameworkcode=";
  strQuery += "&" + "title" + "=" + ""histoire%20algerie"";

Second, the encoding of non-ASCII characters in the search
term was broken.

This patch moves URI escaping from Perl to template with uri TT filter.

Test plan :
- To reproduce the issue with double quotes, the server
  must be running URI::Escape 3.30 or earlier; the current
  version of URI::Escape properly escapes double quote.
- In staff interface, perform a search with double quotes
  that will return no result, ie "aaa xxx"
=> Without patch, javascript is broken
=> With patch, javascript is not broken
- Click on Z3950 button on results page
=> Without patch, the Title input is empty
=> With patch, the Title input contains the search terms

Additional test:
Do a search with something like äöü and then click Z3950
button on results page.
Without patch, encoding is broken in Z3950 form
With patch, encoding is correct.

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Fixed a few tabs. Passes tests and QA script.
I can't reproduce the Javascript problem, but I can reproduce
the Z39.50 encoding problem and can detect no regression.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Fridolin Somers 2014-04-11 10:54:57 +02:00 committed by Galen Charlton
parent 7966037747
commit 064d5478d3
4 changed files with 7 additions and 7 deletions

View file

@ -2251,7 +2251,7 @@ $arrayref = z3950_search_args($matchpoints)
This function returns an array reference that contains the search parameters to be
passed to the Z39.50 search script (z3950_search.pl). The array elements
are hash refs whose keys are name, value and encvalue, and whose values are the
are hash refs whose keys are name and value, and whose values are the
name of a search parameter, the value of that search parameter and the URL encoded
value of that parameter.
@ -2262,7 +2262,7 @@ data is in a hash reference in $matchpoints, as returned by Biblio::GetBiblioDat
If $matchpoints is a scalar, it is assumed to be an unnamed query descriptor, e.g.
a general purpose search argument. In this case, the returned array contains only
entry: the key is 'title' and the value and encvalue are derived from $matchpoints.
entry: the key is 'title' and the value is derived from $matchpoints.
If a search parameter value is undefined or empty, it is not included in the returned
array.
@ -2309,8 +2309,8 @@ sub z3950_search_args {
my $array = [];
for my $field (qw/ lccn isbn issn title author dewey subject /)
{
my $encvalue = URI::Escape::uri_escape_utf8($bibrec->{$field});
push @$array, { name=>$field, value=>$bibrec->{$field}, encvalue=>$encvalue } if defined $bibrec->{$field};
push @$array, { name => $field, value => $bibrec->{$field} }
if defined $bibrec->{$field};
}
return $array;
}

View file

@ -18,7 +18,7 @@
function GetZ3950Terms(){
var strQuery="&frameworkcode=";
[% FOREACH z3950_search_param IN z3950_search_params %]
strQuery += "&" + "[% z3950_search_param.name |html %]" + "=" + "[% z3950_search_param.encvalue |html %]";
strQuery += "&" + "[% z3950_search_param.name |uri %]" + "=" + "[% z3950_search_param.value |uri %]";
[% END %]
return strQuery;
}

View file

@ -232,7 +232,7 @@ function PopupZ3950() {
function GetZ3950Terms(){
var strQuery="&frameworkcode=";
[% FOREACH z3950_search_param IN z3950_search_params %]
strQuery += "&" + "[% z3950_search_param.name %]" + "=" + "[% z3950_search_param.encvalue %]";
strQuery += "&" + "[% z3950_search_param.name |uri %]" + "=" + "[% z3950_search_param.value |uri %]";
[% END %]
return strQuery;
}

View file

@ -28,7 +28,7 @@
function GetZ3950Terms(fw){
var strQuery="&frameworkcode=" + fw;
[% FOREACH z3950_search_param IN z3950_search_params %]
strQuery += "&" + "[% z3950_search_param.name %]" + "=" + "[% z3950_search_param.encvalue %]";
strQuery += "&" + "[% z3950_search_param.name |uri %]" + "=" + "[% z3950_search_param.encvalue |uri %]";
[% END %]
return strQuery;
}