Bug 3326 - xml entity refs display incorrectly in results page if exported and indexed as xml
Summary: xml entity refs display incorrectly in results page if exported and indexed a...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: PATCH-Sent (DO NOT USE) normal (vote)
Assignee: Jared Camins-Esakov
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-13 08:20 UTC by Chris Cormack
Modified: 2013-02-13 11:27 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
patch (3.18 KB, patch)
2011-03-15 12:38 UTC, Nicole C. Engard
Details | Diff | Splinter Review
follow up patch (1.63 KB, patch)
2011-03-16 13:31 UTC, Nicole C. Engard
Details | Diff | Splinter Review
Follow-up patch (reuploaded) (4.09 KB, patch)
2011-03-16 13:42 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
follow up patch 2 (1.73 KB, patch)
2011-03-28 11:56 UTC, Nicole C. Engard
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Cormack 2010-05-21 01:09:10 UTC


---- Reported by rch@liblime.com 2009-06-13 20:20:21 ----

If rebuild_zebra.pl is used with the 'as xml' switch,
the XSLT processing on  opac-results.pl does not handle
xml entity refs properly.

Symptoms:
A record may display like this in search results:
  Standard & Poor's research insight.Report & chart library (North America)
  by Standard & Poor's Compustat Services. 
yet display correctly in the details page.

Steps to reproduce:
  * edit a record, adding an ampersand to the title.
  * rebuild zebra: without -x , the title displays properly in search results.
  * repeat, this time running rebuild_zebra.pl -x
  * the '&' now displays as '&' in  opac-results only.  opac-details is not affected.



---- Additional Comments From cmurdock@ccfls.org 2010-03-18 20:09:38 ----

This applies in the staff interface search results as well.  In the page source, ampersands are written like this:

&



---- Additional Comments From cmurdock@ccfls.org 2010-03-18 21:03:15 ----

This fixes it in the OPAC.  Emailed to patches list.

diff --git a/C4/XSLT.pm b/C4/XSLT.pm
index 8dd7840..b99b994 100644
--- a/C4/XSLT.pm
+++ b/C4/XSLT.pm
@@ -136,6 +136,7 @@ sub XSLTParse4Display {
     $sysxml .= "</sysprefs>\n";
     $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
     $xmlrecord =~ s/\& /\&amp\; /;
+    $xmlrecord=~ s/\&amp\;amp\; /\&amp\; /;
 
     my $parser = XML::LibXML->new();
     # don't die when you find &, >, etc
-- 
1.5.6.5




---- Additional Comments From cmurdock@ccfls.org 2010-04-19 18:46:04 ----

Just mailed a patch that fixes it for non-XSLT search results in the Intranet.



---- Additional Comments From gmcharlt@gmail.com 2010-04-22 10:23:03 ----

Pushed second patch from Cindy Ames.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:09 UTC  ---

This bug was previously known as _bug_ 3326 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3326

Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
   an account here. Reassigning to the person who moved
   it here: chris@bigballofwax.co.nz.
   Previous reporter was rch@liblime.com.
CC member ariana.baker@gmail.com does not have an account here

Comment 1 Galen Charlton 2011-02-09 19:55:16 UTC
This ultimately stems from a bug or misconfiguration in Zebra: when it converts from MARCXML to ISO2709 internally, it doesn't seem to be be converted &amp; entities back to the '&' character.  This has been observed in version 2.0.44 of Zebra.
Comment 2 Nicole C. Engard 2011-03-15 12:38:12 UTC
Created attachment 3301 [details] [review]
patch
Comment 3 Chris Cormack 2011-03-16 07:50:56 UTC
Pushed and merged, please test and mark resolved
Comment 4 Nicole C. Engard 2011-03-16 13:30:56 UTC
Follow up patch signed off and submitted.
Comment 5 Nicole C. Engard 2011-03-16 13:31:14 UTC Comment hidden (obsolete)
Comment 6 Jared Camins-Esakov 2011-03-16 13:42:37 UTC
Created attachment 3323 [details] [review]
Follow-up patch (reuploaded)
Comment 7 Jane Wagner 2011-03-16 13:48:16 UTC
Followup patch works -- signing off
Comment 8 Jared Camins-Esakov 2011-03-16 13:56:01 UTC
My initial patch was too aggressive in stripping out ampersand entities and broke the search results display for records with ampersands when -x was not used with rebuild_zebra.pl -b. The follow-up patch corrects this problem.
Comment 9 Chris Cormack 2011-03-17 22:42:16 UTC
Pushed please test
Comment 10 Jared Camins-Esakov 2011-03-22 11:50:03 UTC
This now works for me. If someone else could confirm and close, I'd be grateful.
Comment 11 Jared Camins-Esakov 2011-03-27 11:56:11 UTC
There will be another follow-up patch. In some circumstances the display in the Staff client isn't fixed.
Comment 12 Nicole C. Engard 2011-03-28 11:56:00 UTC
follow up patch for staff client signed off
Comment 13 Nicole C. Engard 2011-03-28 11:56:32 UTC
Created attachment 3463 [details] [review]
follow up patch 2
Comment 14 Chris Cormack 2011-03-28 23:18:16 UTC
Pushed, please test