[open-ils-commits] r12684 - in trunk/Open-ILS/src/perlmods/OpenILS: Application WWW (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 26 11:27:57 EDT 2009


Author: dbs
Date: 2009-03-26 11:27:55 -0400 (Thu, 26 Mar 2009)
New Revision: 12684

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Log:
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.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2009-03-26 15:21:26 UTC (rev 12683)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm	2009-03-26 15:27:55 UTC (rev 12684)
@@ -1395,6 +1395,9 @@
 		$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 @@
 	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) = @_;
 

Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2009-03-26 15:21:26 UTC (rev 12683)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2009-03-26 15:27:55 UTC (rev 12684)
@@ -74,7 +74,7 @@
 
 		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 @@
 
 	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 @@
 		$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 @@
 		$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 @@
 	}
 
 	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 @@
 
 
 	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 @@
 
 
 	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 @@
 	}
 
    	print $cgi->header( -type => 'application/xml' );
-   	print $U->entityize($U->ampersize($resp->asXML)) . "\n";
+   	print $U->entityize($resp->asXML) . "\n";
     return Apache2::Const::OK;
 }
 



More information about the open-ils-commits mailing list