Skip Menu |

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

Report information
The Basics
Id: 80567
Status: resolved
Priority: 0/
Queue: XML-Parser

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

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



Subject: Parameter entity references in internal subset break parser?
Hi, the first occurrence of a parameter reference in the internal subset fires the default handler. After that the default handler is called for everything instead of the dedicated handlers specified in the constructor to XML::Parser. I wouldn't bet my life on this not being an error in my XML instead of a bug in XML::Parser but all other parsers I have tested (xmllint, Xerces) do not report any well-formedness errors and process everything as expected. The following script (also attached) illustrates the problem. Compare the behavior of the original version to the one where "%common;" removed. It actually doesn't matter whether the file "common.txt" exists. I also didn't see any difference, when NoExpand was set to false. Regards, Guido use strict; use XML::Parser; use Data::Dumper; my $xml = <<EOF; <!DOCTYPE mytype [ <!ENTITY % common SYSTEM "common.txt"> %common; <!-- Remove this line for comparison! --> <!ATTLIST mytype foo CDATA "bar"> ]> <mytype foo="bar"/> EOF sub default_handler { shift; print "Default: ", Dumper \@_ } sub catchall_handler { shift; print "Catch all: ", Dumper \@_ } my $p = XML::Parser->new (NoExpand => 1, Handlers => { Default => \&default_handler, Doctype => \&catchall_handler, DoctypeFin => \&catchall_handler, Attlist => \&catchall_handler, }); $p->parse($xml);
Subject: xml-parser.pl
use strict; use XML::Parser; use Data::Dumper; my $xml = <<EOF; <!DOCTYPE mytype [ <!ENTITY % common SYSTEM "common.txt"> %common; <!ATTLIST mytype foo CDATA "bar"> ]> <mytype foo="bar"/> EOF sub default_handler { shift; print "Default: ", Dumper \@_ } sub catchall_handler { shift; print "Catch all: ", Dumper \@_ } my $p = XML::Parser->new (NoExpand => 1, Handlers => { Default => \&default_handler, Doctype => \&catchall_handler, DoctypeFin => \&catchall_handler, Attlist => \&catchall_handler, }); $p->parse($xml);
Ticket migrated to github as https://github.com/toddr/XML-Parser/issues/53