Skip Menu |
 

This queue is for tickets about the XML-Generator CPAN distribution.

Report information
The Basics
Id: 77323
Status: new
Priority: 0/
Queue: XML-Generator

People
Owner: Nobody in particular
Requestors: bitcard [...] davel.me.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.04
Fixed in: (no value)



Download (untitled) / with headers
text/plain 168b
The attached patches extends XML::Generator to make it escape all characters outside the normal ASCII range if escape => "high-bit" is set. Kind regards, Dave Lambley
Subject: escape_everything.diff
commit 8e9a9b062b6ae9e2fc4a17b58dee5871af53360e Author: Dave Lambley <davel@state51.co.uk> Date: Mon May 21 12:38:13 2012 +0000 Escape anything outside ascii. diff --git a/Generator.pm b/Generator.pm index 4aa9264..fa973aa 100644 --- a/Generator.pm +++ b/Generator.pm @@ -1399,7 +1399,7 @@ sub escape { } } if ($f & ESCAPE_HIGH_BIT) { - $_[0] =~ s/([\200-\377])/'&#'.ord($1).';'/ge; + $_[0] =~ s/([^\x00-\x7f])/'&#'.ord($1).';'/ge; } if ($f & ESCAPE_FILTER_INVALID_CHARS) { filter($_[0]); diff --git a/t/Generator.t b/t/Generator.t index e2dc48f..c9299e3 100644 --- a/t/Generator.t +++ b/t/Generator.t @@ -264,6 +264,9 @@ $x = XML::Generator->new(':strict', escape => 'high-bit'); $xml = $x->foo("\\<\242", $x->xmlpi('g')); ok($xml, '<foo><&#162;<?g?></foo>'); +$xml = $x->foo("\\<\x{2603}", $x->xmlpi('g')); +ok($xml, '<foo><&#9731xxx;<?g?></foo>'); + { my $w; local $SIG{__WARN__} = sub { $w .= $_[0] }; $x = XML::Generator->new(':import'); ok($w =~ /Useless use of/, 1); $w = '';


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.