From 73e9d4b024ffbeb2af9b0e67b470fe0081c54da9 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 10 Aug 2007 17:16:17 +0000 Subject: [PATCH] escaping xml entities in xhmtl output git-svn-id: svn://svn.open-ils.org/ILS/trunk@7659 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/org_tree_html_options.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/extras/org_tree_html_options.pl b/Open-ILS/src/extras/org_tree_html_options.pl index cefb22bee8..a65224d8b2 100644 --- a/Open-ILS/src/extras/org_tree_html_options.pl +++ b/Open-ILS/src/extras/org_tree_html_options.pl @@ -5,6 +5,7 @@ use OpenSRF::AppSession; use OpenSRF::System; use OpenILS::Utils::Fieldmapper; use OpenSRF::Utils::SettingsClient; +use Unicode::Normalize; die "usage: perl org_tree_html_options.pl " unless $ARGV[1]; OpenSRF::System->bootstrap_client(config_file => $ARGV[0]); @@ -26,11 +27,23 @@ close FILE; 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 "\n"; + + print FILE "\n"; print_option($_) for (@$kids); } +sub entityize { + my $stuff = shift || return ""; + $stuff =~ s/\/>/og; + $stuff =~ s/\&/&/og; + $stuff = NFC($stuff); + $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe; + return $stuff; +} + -- 2.11.0