Skip Menu |
 

This queue is for tickets about the Pod-SAX CPAN distribution.

Report information
The Basics
Id: 83866
Status: open
Priority: 0/
Queue: Pod-SAX

People
Owner: Nobody in particular
Requestors: BRIANC [...] cpan.org
Cc:
AdminCc:

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

Attachments
0001-Handle-octal-and-hexadecimal-entities.patch



Subject: Mishandles octal and hexadecimal entities
Download (untitled) / with headers
text/plain 433b
man perlpod (for 5.14) states for E<number>: The ASCII/Latin-1/Unicode character with that number. A leading "0x" means that number is hex, as in "E<0x201E>". A leading "0" means that number is octal, as in "E<075>". Otherwise number is interpreted as being in decimal, as in "E<181>". Pod::SAX does not understand octal or hexadecimal entities. What's worse, it treats octal entities as decimal, producing bad output.
Download (untitled) / with headers
text/plain 554b
On Sun Mar 10 18:22:17 2013, BRIANC wrote: Show quoted text
> man perlpod (for 5.14) states for E<number>: > > The ASCII/Latin-1/Unicode character with that number. A leading "0x" > means that number is hex, as in "E<0x201E>". A leading "0" means
that Show quoted text
> number is octal, as in "E<075>". Otherwise number is interpreted as > being in decimal, as in "E<181>". > > Pod::SAX does not understand octal or hexadecimal entities. What's > worse, it treats octal entities as decimal, producing bad output.
I've included a patch for this, including a test script.
Subject: 0001-Handle-octal-and-hexadecimal-entities.patch
From c96daeb937be5eb8ae3856e6aa2ff85d7ee9e957 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" <sandals@crustytoothpaste.net> Date: Sun, 10 Mar 2013 22:37:18 +0000 Subject: [PATCH] Handle octal and hexadecimal entities. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> --- lib/Pod/SAX.pm | 8 +++++++- t/17entites.t | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 t/17entites.t diff --git a/lib/Pod/SAX.pm b/lib/Pod/SAX.pm index 54dbf5b..de4ea74 100644 --- a/lib/Pod/SAX.pm +++ b/lib/Pod/SAX.pm @@ -505,7 +505,13 @@ sub expand_seq { elsif ($name eq 'E') { my $text = join('', $sequence->parse_tree->children); my $char; - if ($text =~ /^\d+$/) { + if ($text =~ /^0\d+$/) { + $char = chr(oct($text)); + } + elsif ($text =~ /^0x\d+$/) { + $char = chr(hex($text)); + } + elsif ($text =~ /^\d+$/) { $char = chr($text); } else { diff --git a/t/17entites.t b/t/17entites.t new file mode 100644 index 0000000..12f592e --- /dev/null +++ b/t/17entites.t @@ -0,0 +1,30 @@ +use Test; +BEGIN { plan tests => 4 } +use Pod::SAX; +use XML::SAX::Writer; + +my $output = ''; +my $p = Pod::SAX->new( + Handler => XML::SAX::Writer->new( + Output => \$output + ) + ); + +ok($p); +$p->parse_file(\*DATA); +ok($output); +print "$output\n"; +ok($output, qr/<pod>.*<\/pod>/s, "Matches basic pod outline"); +ok($output, qr/paragraph/, "Contains a link"); + +__DATA__ + +=head1 NAME + +SomePod - Some Pod to parse + +=head1 DESCRIPTION + +The word B<< pE<97>rE<0x61>grE<0141>ph >> contains 3 I<a>s. + +=cut -- 1.8.0


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.