Bug 14716: URI-encode URLs in UNIMARC xsl templates.
authorEre Maijala <ere.maijala@helsinki.fi>
Thu, 22 Feb 2018 13:37:25 +0000 (15:37 +0200)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 31 Oct 2018 13:19:21 +0000 (13:19 +0000)
https://bugs.koha-community.org/show_bug.cgi?id=14716

Test plan:

1. Catalog a record with series name "Series & more"
2. Find the record
3. Make sure clicking the "Series & more" link works and the ampersand is properly encoded in the URL.
4. Also try the attached test records and make sure their links work.

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslimUtils.xsl

index 65ec306..e78e8d7 100644 (file)
@@ -6,7 +6,8 @@
   xmlns:marc="http://www.loc.gov/MARC21/slim"
   xmlns:items="http://www.koha-community.org/items"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  exclude-result-prefixes="marc items">
+  xmlns:str="http://exslt.org/strings"
+  exclude-result-prefixes="marc items str">
 
   <xsl:template name="datafield">
     <xsl:param name="tag"/>
                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su:<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/></xsl:attribute>
               </xsl:otherwise>
             </xsl:choose>
             <xsl:call-template name="chopPunctuation">
                   <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
                 </xsl:when>
                 <xsl:otherwise>
-                  <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='b']"/></xsl:attribute>
+                  <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='b']"/></xsl:attribute>
                 </xsl:otherwise>
               </xsl:choose>
               <xsl:if test="marc:subfield[@code='a']">
index 97206aa..00c0741 100644 (file)
@@ -6,7 +6,8 @@
   xmlns:marc="http://www.loc.gov/MARC21/slim"
   xmlns:items="http://www.koha-community.org/items"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  exclude-result-prefixes="marc items">
+  xmlns:str="http://exslt.org/strings"
+  exclude-result-prefixes="marc items str">
 
   <xsl:template name="datafield">
     <xsl:param name="tag"/>
         <a>
           <xsl:attribute name="href">
             <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
-            <xsl:value-of select="marc:subfield[@code='a']"/>
+            <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
           </xsl:attribute>
           <xsl:call-template name="chopPunctuation">
             <xsl:with-param name="chopString">
                 <xsl:otherwise>
                   <xsl:attribute name="href">
                     <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
-                    <xsl:value-of select="marc:subfield[@code='a']"/>
-                    <xsl:text> </xsl:text>
-                    <xsl:value-of select="marc:subfield[@code='b']"/>
+                    <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
+                    <xsl:text>%20</xsl:text>
+                    <xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>
                   </xsl:attribute>
                 </xsl:otherwise>
               </xsl:choose>