Skip Menu |

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

Report information
The Basics
Id: 15974
Status: resolved
Priority: 0/
Queue: XML-Mini

People
Owner: Nobody in particular
Requestors: eric [...] eb.homelinux.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: XML::Mini doesn't handle empty attribute (attr='') or value ending with = (attr='base64=')
Hi, XML::Mini doesn't handle empty attribute (attr='') or value ending with = (attr='base64=') please try this perl script : ----8<--------8<----------------- #!/usr/bin/perl -w use strict ; use XML::Mini::Document ; use Data::Dumper qw/Dumper/; # create a new object my $XMLString = '<test id="test1=" id2="test2"/>' ; my $xmlDoc = XML::Mini::Document->new(); $xmlDoc->parse($XMLString); my $xmlHash = $xmlDoc->toHash(); print Dumper($xmlHash); $XMLString = '<test id="" id2="test2"/>' ; $xmlDoc = XML::Mini::Document->new(); $xmlDoc->parse($XMLString); $xmlHash = $xmlDoc->toHash(); print Dumper($xmlHash); ----8<--------8<----------------- You will see $VAR1 = { 'test' => { 'id="test1' => ' id2=' } }; $VAR1 = { 'test' => { 'id' => '" id2=' } }; Instead of $VAR1 = { 'test' => { 'id2' => 'test2', 'id' => 'test1=' } }; $VAR1 = { 'test' => { 'id2' => 'test2', 'id' => '' } }; You can fix this nasty bug with the following patch (cd src ; patch -p1 < p) Please, fix this... ---------8<----------------------8<--------------------- --- org/XML/Mini/Document.pm 2004-10-01 23:03:20.000000000 +0200 +++ new/XML/Mini/Document.pm 2004-10-22 21:30:49.000000000 +0200 @@ -761,0 +761,0 @@ return undef unless (defined $attrString); my $count = 0; - while ($attrString =~ /([^\s]+)\s*=\s*(['"])([^\2]+?)\2/g) + while ($attrString =~ /([^\s]+?)\s*=\s*(['"])([^\2]*?)\2/g) { my $attrname = $1; my $attrval = $3; ---------8<----------------------8<--------------------- And i have a warning in strict mode when i use parent option, Use of uninitialized value in numeric eq (==) at /usr/share/perl5/XML/Mini/Element.pm line 464. you can avoid it with this patch : ---------8<----------------------8<--------------------- --- /tmp/Element.pm 2005-08-09 20:13:41.627412112 +0200 +++ Element.pm 2005-08-06 11:01:08.000000000 +0200 @@ -461,7 +461,7 @@ if ($self->{'_avoidLoops'} || $XML::Mini::AutoSetParent) { - if ($self->{'_parent'} == $child) + if ($self->{'_parent'} && $self->{'_parent'} == $child) { my $childName = $child->name(); ---------8<----------------------8<--------------------- Regards,
--- org/XML/Mini/Document.pm 2004-10-01 23:03:20.000000000 +0200 +++ new/XML/Mini/Document.pm 2004-10-22 21:30:49.000000000 +0200 @@ -761,0 +761,0 @@ return undef unless (defined $attrString); my $count = 0; - while ($attrString =~ /([^\s]+)\s*=\s*(['"])([^\2]+?)\2/g) + while ($attrString =~ /([^\s]+?)\s*=\s*(['"])([^\2]*?)\2/g) { my $attrname = $1; my $attrval = $3;
Thanks. Finally resolved in .38. Regards, Pat D