From: dbs Date: Thu, 26 Mar 2009 15:27:55 +0000 (+0000) Subject: Apply ampersand escaping globally in entityize (fixes a problem with names containing... X-Git-Tag: sprint4-merge-nov22~10403 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2837ac0b0ae4256b3686929c83b6e1e6563f100d;p=working%2FEvergreen.git Apply ampersand escaping globally in entityize (fixes a problem with names containing & in org_tree_html.pl) We will probably need to escape < as well. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12684 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm index 063ed08a96..da095d2b00 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm @@ -1395,6 +1395,9 @@ sub entityize { $string = NFC($string); } + # Convert raw ampersands to ampersand entities + $string =~ s/&(?!\S+;)/&/gso; + $string =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe; return $string; } @@ -1408,14 +1411,6 @@ sub strip_ctrl_chars { return $string; } -# Ampersands are special, mmmkay? -# XXX Perhaps this should go into our standard entityize method -sub ampersize { - my $stuff = shift(); - $stuff =~ s/&(?!\S+;)/&/gso; - return $stuff; -} - sub get_copy_price { my($self, $e, $copy, $volume) = @_; diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 4680fc84a8..86f1a894c1 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -74,7 +74,7 @@ $browse_types{call_number}{xml} = sub { my $r_doc = $parser->parse_string($cn->record->marc); $r_doc->documentElement->setAttribute( id => $rec_tag ); - $content .= $U->entityize($U->ampersize($r_doc->documentElement->toString)); + $content .= $U->entityize($r_doc->documentElement->toString); $content .= ""; } @@ -103,13 +103,13 @@ $browse_types{call_number}{html} = sub { return ( "Content-type: text/html\n\n", - $U->entityize($U->ampersize( + $U->entityize( $cn_browse_xslt->transform( $parser->parse_string( $xml ), 'prev' => "'$p'", 'next' => "'$n'" )->toString(1) - )) + ) ); }; @@ -453,7 +453,7 @@ sub unapi { $feed->link( unapi => $base) if ($flesh_feed); print "Content-type: ". $feed->type ."; charset=utf-8\n\n"; - print $U->entityize($U->ampersize($feed->toString)) . "\n"; + print $U->entityize($feed->toString) . "\n"; return Apache2::Const::OK; } @@ -699,7 +699,7 @@ sub supercat { $feed->link( unapi => $base) if ($flesh_feed); print "Content-type: ". $feed->type ."; charset=utf-8\n\n"; - print $U->entityize($U->ampersize($feed->toString)) . "\n"; + print $U->entityize($feed->toString) . "\n"; return Apache2::Const::OK; } @@ -724,7 +724,7 @@ sub supercat { } print "Content-type: application/xml; charset=utf-8\n\n"; - print $U->entityize($U->ampersize( $parser->parse_string( $req->gather(1) )->documentElement->toString )); + print $U->entityize( $parser->parse_string( $req->gather(1) )->documentElement->toString ); return Apache2::Const::OK; } @@ -800,7 +800,7 @@ sub bookbag_feed { print "Content-type: ". $feed->type ."; charset=utf-8\n\n"; - print $U->entityize($U->ampersize($feed->toString)) . "\n"; + print $U->entityize($feed->toString) . "\n"; return Apache2::Const::OK; } @@ -869,7 +869,7 @@ sub changes_feed { print "Content-type: ". $feed->type ."; charset=utf-8\n\n"; - print $U->entityize($U->ampersize($feed->toString)) . "\n"; + print $U->entityize($feed->toString) . "\n"; return Apache2::Const::OK; } @@ -1631,7 +1631,7 @@ sub sru_search { } print $cgi->header( -type => 'application/xml' ); - print $U->entityize($U->ampersize($resp->asXML)) . "\n"; + print $U->entityize($resp->asXML) . "\n"; return Apache2::Const::OK; }