Subject: | Bug XML/SAX/PurePerl.pm, sub CDSect |
Date: | Tue, 10 Feb 2009 11:07:48 +0100 |
To: | bug-XML-SAX [...] rt.cpan.org |
From: | Herbert Schiemann <h.schiemann [...] laemmerzahl.de> |
Hello,
I have to fix my last message. The test for EOF should be modified as
shown. I'm using XML-SAX-0.96.
sub CDSect in file XML/SAX/PurePerl.pm should be like
sub CDSect {
my ($self, $reader) = @_;
my $data = $reader->data(9);
return 0 unless $data =~ /^<!\[CDATA\[/;
$reader->move_along(9);
$self->start_cdata({});
my $chars;
while (1) {
# do not miss "]]>", so try to read at least 3 chars
$data = $reader->data(3);
$self->parser_error
("EOF looking for CDATA section end", $reader)
unless length($data) >= 3;
if ($data =~ /^(.*?)\]\]>/s) {
$chars = $1;
$reader->move_along(length($chars) + 3);
$self->characters({Data => $chars});
last;
}
else {
# the last one or two "]" could be the beginning of a "]]>",
# so do no eat them
$data =~ /^(.*?)\]{0,2}+$/s;
$chars = $1;
$reader->move_along(length($chars));
$self->characters({Data => $chars});
}
}
$self->end_cdata({});
return 1;
}
Regards, Herbert