Bugzilla – Attachment 182059 Details for
Bug 39860
Add a system preference to allow for addtional/custom MARC fields in the record display
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39860: Fix scrubbing and handling of HTML/TT in MARC21 xsl
Bug-39860-Fix-scrubbing-and-handling-of-HTMLTT-in-.patch (text/plain), 6.11 KB, created by
Lucas Gass (lukeg)
on 2025-05-08 00:16:10 UTC
(
hide
)
Description:
Bug 39860: Fix scrubbing and handling of HTML/TT in MARC21 xsl
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-05-08 00:16:10 UTC
Size:
6.11 KB
patch
obsolete
>From 89a3c8078876076804702a18b17db64e06db59f6 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 8 May 2025 00:15:47 +0000 >Subject: [PATCH] Bug 39860: Fix scrubbing and handling of HTML/TT in MARC21 > xsl > >--- > C4/XSLT.pm | 4 +- > .../en/xslt/MARC21slim2intranetDetail.xsl | 40 +++++++++++++++++-- > .../en/xslt/MARC21slim2intranetResults.xsl | 39 ++++++++++++++++-- > 3 files changed, 74 insertions(+), 9 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 04dad6ca486..7d7cbfb8794 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -245,11 +245,11 @@ sub XSLTParse4Display { > # Check if we should add extra content based on system preference > if ( C4::Context->preference('ExtraContentForXSLTDisplay') ) { > >- my $scrubber = C4::Scrubber->new(); >+ my $scrubber = C4::Scrubber->new('staff'); > my $extracontentvalue = C4::Context->preference('ExtraContentForXSLTDisplay'); > my $extracontentproccessed = process_tt( $extracontentvalue, { record => $record } ); > my $cleanxml = $scrubber->scrub($extracontentproccessed); >- $extracontentxml = "<extracontent><content>" . $cleanxml . "</content></extracontent>"; >+ $extracontentxml = qq{<extracontent><content>$cleanxml</content></extracontent>}; > } > > # embed variables >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >index fb08b541114..f75b795604b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >@@ -14,7 +14,24 @@ > <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> >- >+ <!-- Template for adding custom content from ExtraContentForXSLTDisplay and preserving HTML and TT from the preference --> >+ <xsl:template match="marc:extracontent//node()"> >+ <xsl:choose> >+ <xsl:when test="self::text() or self::comment()"> >+ <xsl:value-of select="."/> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:element name="{local-name()}"> >+ <xsl:for-each select="@*"> >+ <xsl:attribute name="{name()}"> >+ <xsl:value-of select="."/> >+ </xsl:attribute> >+ </xsl:for-each> >+ <xsl:apply-templates select="node()"/> >+ </xsl:element> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:template> > <xsl:template match="marc:record"> > > <!-- Option: Display Alternate Graphic Representation (MARC 880) --> >@@ -1568,10 +1585,25 @@ > </xsl:for-each> > </span> > </xsl:if> >- <xsl:if test="marc:extracontent and normalize-space(string(marc:extracontent/marc:content)) != ''"> >- <xsl:copy-of select="marc:extracontent/marc:content/node()"/> >- </xsl:if> > >+ <!-- Process custom fields from ExtraContentForXSLTDisplay system preference --> >+ <xsl:for-each select="marc:extracontent/marc:content/node()"> >+ <xsl:choose> >+ <xsl:when test="self::text() or self::comment()"> >+ <xsl:value-of select="."/> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:element name="{local-name()}"> >+ <xsl:for-each select="@*"> >+ <xsl:attribute name="{name()}"> >+ <xsl:value-of select="."/> >+ </xsl:attribute> >+ </xsl:for-each> >+ <xsl:apply-templates select="node()"/> >+ </xsl:element> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:for-each> > > <!-- Indicate if record is suppressed in OPAC --> > <xsl:choose> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl >index 36045762547..6742d00fd5a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl >@@ -12,6 +12,24 @@ > <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> >+ <!-- Template for adding custom content from ExtraContentForXSLTDisplay and preserving HTML and TT from the preference --> >+ <xsl:template match="marc:extracontent//node()"> >+ <xsl:choose> >+ <xsl:when test="self::text() or self::comment()"> >+ <xsl:value-of select="."/> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:element name="{local-name()}"> >+ <xsl:for-each select="@*"> >+ <xsl:attribute name="{name()}"> >+ <xsl:value-of select="."/> >+ </xsl:attribute> >+ </xsl:for-each> >+ <xsl:apply-templates select="node()"/> >+ </xsl:element> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:template> > <xsl:template match="marc:record"> > > <!-- Option: Display Alternate Graphic Representation (MARC 880) --> >@@ -1021,9 +1039,24 @@ > </span> > </xsl:if> > </xsl:if> >- <xsl:if test="marc:extracontent and normalize-space(string(marc:extracontent/marc:content)) != ''"> >- <xsl:copy-of select="marc:extracontent/marc:content/node()"/> >- </xsl:if> >+ <!-- Process custom fields from ExtraContentForXSLTDisplay system preference --> >+ <xsl:for-each select="marc:extracontent/marc:content/node()"> >+ <xsl:choose> >+ <xsl:when test="self::text() or self::comment()"> >+ <xsl:value-of select="."/> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:element name="{local-name()}"> >+ <xsl:for-each select="@*"> >+ <xsl:attribute name="{name()}"> >+ <xsl:value-of select="."/> >+ </xsl:attribute> >+ </xsl:for-each> >+ <xsl:apply-templates select="node()"/> >+ </xsl:element> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:for-each> > > <!-- Content Warning --> > <xsl:variable name="ContentWarningField" select="marc:sysprefs/marc:syspref[@name='ContentWarningField']"/> >-- >2.39.5
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 39860
:
182054
|
182055
|
182056
|
182057
|
182058
|
182059
|
182230
|
182231
|
182232
|
182233