Bugzilla – Attachment 67622 Details for
Bug 16804
Searching can be broken by search terms containing semicolons in XSLT
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16804 - unescaped semicolons in XSLT values can cause searches to fail
Bug-16804---unescaped-semicolons-in-XSLT-values-ca.patch (text/plain), 6.20 KB, created by
Liz Rea
on 2017-10-05 02:08:40 UTC
(
hide
)
Description:
Bug 16804 - unescaped semicolons in XSLT values can cause searches to fail
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2017-10-05 02:08:40 UTC
Size:
6.20 KB
patch
obsolete
>From 4230e05feadc887454badbc737006ee8b2ed829f Mon Sep 17 00:00:00 2001 >From: Liz Rea <liz@catalyst.net.nz> >Date: Tue, 4 Jul 2017 14:22:58 +1200 >Subject: [PATCH] Bug 16804 - unescaped semicolons in XSLT values can cause > searches to fail > >This patch adds a url-encode to the MARC21slimUtils, and applies it specifically to a common place where semicolons can appear in searches, the 490 field. > >To test: > >* have OPACSuppression on >* have a record with a 490 field a la: > >490 _a something ; > _v 123 > >* go to the opac and search for this record >* click the Series link from the detail > >Without this patch, there will be no results. > >With this patch, you will get relevant results (possibly the same record back) > >There are probably lots of places this could be applied, and also possibly many other solutions. >--- > .../bootstrap/en/xslt/MARC21slim2OPACDetail.xsl | 4 +- > .../bootstrap/en/xslt/MARC21slimUtils.xsl | 56 ++++++++++++++++++++++ > 2 files changed, 58 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >index f31b1be..e480dc0 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >@@ -221,7 +221,7 @@ > > <!-- 490 Series not traced, Ind1 = 0 --> > <xsl:for-each select="marc:datafield[@tag=490][@ind1!=1]"> >- <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute> >+ <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:call-template name="url-encode"><xsl:with-param name="str"><xsl:value-of select="marc:subfield[@code='a']"/></xsl:with-param></xsl:call-template>"</xsl:attribute> > <xsl:call-template name="chopPunctuation"> > <xsl:with-param name="chopString"> > <xsl:call-template name="subfieldSelect"> >@@ -249,7 +249,7 @@ > </a> > </xsl:when> > <xsl:otherwise> >- <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute> >+ <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:call-template name="url-encode"><xsl:with-param name="str"><xsl:value-of select="marc:subfield[@code='a']"/></xsl:with-param></xsl:call-template>"</xsl:attribute> > <xsl:call-template name="chopPunctuation"> > <xsl:with-param name="chopString"> > <xsl:call-template name="subfieldSelect"> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl >index 596bddf..3d520e0 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl >@@ -1,6 +1,22 @@ > <?xml version='1.0'?> > <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]> > <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc"> >+ <!-- url encoding --> >+ >+ <xsl:variable name="ascii"> >+ <xsl:text> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text> >+ </xsl:variable> >+ >+ <xsl:variable name="latin1"> >+ <xsl:text> ¡¢£¤¥¦§¨©ª«¬Â®¯°±²³´µ¶·¸¹º»¼½¾¿ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûüýþÿ</xsl:text> >+ </xsl:variable> >+ <!-- Characters that usually don't need to be escaped --> >+ <xsl:variable name="safe"> >+ <xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text> >+ </xsl:variable> >+ >+ <xsl:variable name="hex">0123456789ABCDEF</xsl:variable> >+ > <xsl:template name="datafield"> > <xsl:param name="tag"/> > <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param> >@@ -295,6 +311,46 @@ > > </span> > </xsl:template> >+ >+ <xsl:template name="url-encode"> >+ <xsl:param name="str"/> >+ <xsl:if test="$str"> >+ <xsl:variable name="first-char" select="substring($str,1,1)"/> >+ <xsl:choose> >+ <xsl:when test="contains($safe,$first-char)"> >+ <xsl:value-of select="$first-char"/> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:variable name="codepoint"> >+ <xsl:choose> >+ <xsl:when test="contains($ascii,$first-char)"> >+ <xsl:value-of select="string-length(substring-before($ascii,$first-char)) + 32"/> >+ </xsl:when> >+ <xsl:when test="contains($latin1,$first-char)"> >+ <xsl:value-of select="string-length(substring-before($latin1,$first-char)) + 160"/> >+ <!-- was 160 --> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:message terminate="no">Warning: string contains a character that is out of range! Substituting "?".</xsl:message> >+ <xsl:text>63</xsl:text> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:variable> >+ <xsl:variable name="hex-digit1" select="substring($hex,floor($codepoint div 16) + 1,1)"/> >+ <xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/> >+ <xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/> >+ </xsl:otherwise> >+ </xsl:choose> >+ <xsl:if test="string-length($str) > 1"> >+ <xsl:call-template name="url-encode"> >+ <xsl:with-param name="str" select="substring($str,2)"/> >+ </xsl:call-template> >+ </xsl:if> >+ </xsl:if> >+ </xsl:template> >+ >+ >+ > </xsl:stylesheet> > > <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp. >-- >2.7.4
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 16804
:
67622
|
70241
|
76064