[open-ils-commits] r7659 - trunk/Open-ILS/src/extras
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Aug 10 13:19:31 EDT 2007
Author: miker
Date: 2007-08-10 13:16:17 -0400 (Fri, 10 Aug 2007)
New Revision: 7659
Modified:
trunk/Open-ILS/src/extras/org_tree_html_options.pl
Log:
escaping xml entities in xhmtl output
Modified: trunk/Open-ILS/src/extras/org_tree_html_options.pl
===================================================================
--- trunk/Open-ILS/src/extras/org_tree_html_options.pl 2007-08-10 15:37:57 UTC (rev 7658)
+++ trunk/Open-ILS/src/extras/org_tree_html_options.pl 2007-08-10 17:16:17 UTC (rev 7659)
@@ -5,6 +5,7 @@
use OpenSRF::System;
use OpenILS::Utils::Fieldmapper;
use OpenSRF::Utils::SettingsClient;
+use Unicode::Normalize;
die "usage: perl org_tree_html_options.pl <bootstrap_config> <output_file>" unless $ARGV[1];
OpenSRF::System->bootstrap_client(config_file => $ARGV[0]);
@@ -26,11 +27,23 @@
sub print_option {
my $node = shift;
return unless ($node->opac_visible =~ /^[y1t]+/i);
+
my $depth = $node->ou_type - 1;
- my $sname = $node->shortname;
- my $name = $node->name;
+ my $sname = entityize($node->shortname);
+ my $name = entityize($node->name);
my $kids = $node->children;
- print FILE "<option value='$sname'><pre>" . ' 'x$depth . "</pre>$name</option>\n";
+
+ print FILE "<option value='$sname'><pre>" . '   'x$depth . "</pre>$name</option>\n";
print_option($_) for (@$kids);
}
+sub entityize {
+ my $stuff = shift || return "";
+ $stuff =~ s/\</</og;
+ $stuff =~ s/\>/>/og;
+ $stuff =~ s/\&/&/og;
+ $stuff = NFC($stuff);
+ $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
+ return $stuff;
+}
+
More information about the open-ils-commits
mailing list