I'm using v1.28 of the perl module XML::Mini with perl
5.8.3 on SUSE Linux
I've discovered that the XML parser has a problem with
empty attributes, as in <foo bar="" baz="qux">
In the above example, calling
XML::Mini::Element::attribute('baz') returns undef, and
calling attribute('bar') returns
" baz=
including the leading quotation mark. Here is a script
to reproduce the bug:
#!/usr/bin/perl
use XML::Mini::Document;
$xml = '<foo wibble="" wobble="bar">Hello</foo>';
$xml_doc = XML::Mini::Document->new($xml);
$element = $xml_doc->getElement('foo');
$wibble = $element->attribute('wibble');
$wobble = $element->attribute('wobble');
print "wibble: $wibble\nwobble: $wobble\n";
It produces the following output:
Use of uninitialized value in concatenation (.) or
string at ./minixml-test line 11.
wibble: " wobble=
wobble:
Regards,
Misha Gale
Logged In: YES
user_id=621849
I've found the fix for this problem; change line 764 of
Document.pm from
while ($attrString =~ /([^\s]+)\s*=\s*(['"])([^\2]+?)\2/g)
to
while ($attrString =~ /([^\s]+)\s*=\s*(['"])([^\2]*?)\2/g)
All that was required was to change a + to a *