added check for broken CDATA at beginning, fix also broken delimiters
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 6 Jun 2006 12:22:52 +0000 (12:22 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 6 Jun 2006 12:22:52 +0000 (12:22 +0000)
git-svn-id: file:///home/dpavlin/private/svn/webpac/branches/hidra@745 13eb9ef6-21d5-0310-b721-a9d68796d827

all2xml.pl

index 6ff09a8..128b1ec 100755 (executable)
@@ -76,6 +76,9 @@ my $use_lhash_cache = 1;
 
 my $last_field_name;   # cache to prevent repeated fields
 
+my $broken_cdata = XMLin('<foo><![CDATA[<bar>]]></foo>') eq '<bar>>';
+warn "XML::Simple on this system seems broken with <![CDATA[..]]>.\n" if ($broken_cdata);
+
 sub data2xml {
 
        use xmlify;
@@ -207,6 +210,7 @@ sub data2xml {
                        delete $x->{value};
                        delete $x->{delimiter};
                        $x->{content} = $v;
+                       $d =~ s#>$## if ($d && $broken_cdata);
                        $x->{delimiter} = $d;
                }
                return $x;
@@ -706,8 +710,7 @@ foreach my $database ($cfg->Sections) {
        $config=XMLin($import_xml_file, ForceArray => [ $tag, 'config', 'format' ], ForceContent => 1 );
 
        # check for broken XML::Simple
-       if ( XMLin('<foo><![CDATA[<bar>]]></foo>') eq '<bar>>' ) {
-               warn "XML::Simple on this system seems broken with <![CDATA[..]]>.\n";
+       if ( $broken_cdata ) {
                map {
                        $config->{format}->{$_}->{content} =~ s#>$##;
                } keys %{ $config->{format} };