[Po4a-commits] po4a/lib/Locale/Po4a Sgml.pm,1.49,1.50
Nicolas FRANCOIS
po4a-devel@lists.alioth.debian.org
Wed, 11 May 2005 23:16:14 +0000
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv3794/lib/Locale/Po4a
Modified Files:
Sgml.pm
Log Message:
Change <, > and & to {PO4A-lt}, {PO4A-gt} and {PO4A-amp} before feeding
nsgmls.
This fixes #301335 in the tracker.
Index: Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- Sgml.pm 11 May 2005 23:05:29 -0000 1.49
+++ Sgml.pm 11 May 2005 23:16:12 -0000 1.50
@@ -450,7 +450,19 @@
# protect the conditional inclusions in the file
$origfile =~ s/<!\[(\s*[^\[]+)\[/{PO4A-beg-$1}/g; # cond. incl. starts
$origfile =~ s/\]\]>/{PO4A-end}/g; # cond. incl. end
-
+
+ my $tmp1 = $origfile;
+ $origfile = "";
+ while ($tmp1 =~ m/^(.*?{PO4A-beg-[^}]*})(.+?)({PO4A-end}.*)$/s) {
+ my ($begin, $tmp) = ($1, $2);
+ $tmp1 = $3;
+ $tmp =~ s/</{PO4A-lt}/gs;
+ $tmp =~ s/>/{PO4A-gt}/gs;
+ $tmp =~ s/&/{PO4A-amp}/gs;
+ $origfile .= $begin.$tmp;
+ }
+ $origfile .= $tmp1;
+
# Deal with the %entities; in the prolog. God damn it, this code is gross!
# Try hard not to change the number of lines to not fuck up the references
my %prologentincl;
@@ -793,6 +805,9 @@
elsif ($event->type eq 'cdata') {
my $cdata = $event->data;
+ $cdata =~ s/{PO4A-lt}/</g;
+ $cdata =~ s/{PO4A-gt}/>/g;
+ $cdata =~ s/{PO4A-amp}/&/g;
if ($cdata =~ /^(({PO4A-(beg|end)[^\}]*})|\s)+$/ &&
$cdata =~ /\S/) {
$cdata =~ s/\s*{PO4A-end}/\]\]>\n/g;