Fix canonical_system_definition.xml doesn't have XML special characters escaped
authorDario Sestito <darios@symbian.org>
Fri, 09 Apr 2010 10:34:32 +0100
changeset 961 94716c328941
parent 960 b0315c337be6
child 962 a5e5d79cd09a
Fix canonical_system_definition.xml doesn't have XML special characters escaped
common/tools/csvToSysDef.pl
common/tools/lib/XML/Printer.pm
--- a/common/tools/csvToSysDef.pl	Wed Apr 07 14:03:14 2010 +0100
+++ b/common/tools/csvToSysDef.pl	Fri Apr 09 10:34:32 2010 +0100
@@ -153,7 +153,14 @@
 	$tagName =~ s{^main::}{};
 	if ($tagName eq "Characters")
 	{
-		print $tree->{Text};
+		if ($tree->{Text} =~ m{[<>&]})
+		{
+			print "<![CDATA[$tree->{Text}]]>";
+		}
+		else
+		{
+			print $tree->{Text};
+		}
 		return;
 	}
 	
@@ -172,7 +179,11 @@
 		}
 		keys %$tree)
 	{
-		print " $attr=\"$tree->{$attr}\"";
+		my $value_escaped = $tree->{$attr};
+		$value_escaped =~ s/&/&amp;/g;
+		$value_escaped =~ s/</&lt;/g;
+		$value_escaped =~ s/>/&gt;/g;
+		print " $attr=\"$value_escaped\"";
 	}
 
 	my $children = $tree->{Kids};
--- a/common/tools/lib/XML/Printer.pm	Wed Apr 07 14:03:14 2010 +0100
+++ b/common/tools/lib/XML/Printer.pm	Fri Apr 09 10:34:32 2010 +0100
@@ -55,7 +55,11 @@
 		}
 		keys %$tree)
 	{
-		print " $attr=\"$tree->{$attr}\"";
+		my $value_escaped = $tree->{$attr};
+		$value_escaped =~ s/&/&amp;/g;
+		$value_escaped =~ s/</&lt;/g;
+		$value_escaped =~ s/>/&gt;/g;
+		print " $attr=\"$value_escaped\"";
 	}
 
 	my $children = $tree->{Kids} || [];