Apply ampersand escaping globally in entityize (fixes a problem with names containing...
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 26 Mar 2009 15:27:55 +0000 (15:27 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 26 Mar 2009 15:27:55 +0000 (15:27 +0000)
We will probably need to escape < as well.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@12684 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm

index 063ed08..da095d2 100644 (file)
@@ -1395,6 +1395,9 @@ sub entityize {
                $string = NFC($string);
        }
 
+       # Convert raw ampersands to ampersand entities
+       $string =~ s/&(?!\S+;)/&amp;/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+;)/&amp;/gso;
-       return $stuff;
-}
-
 sub get_copy_price {
        my($self, $e, $copy, $volume) = @_;
 
index 4680fc8..86f1a89 100644 (file)
@@ -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 .= "</hold:volume>";
        }
@@ -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;
 }