Subject: | autodetection of XML datatyp <i4> for string of digits starting with 0 |
So far data type i4 is matched as
m/^[\-+]?\d+$/
unfortunately this will match not only strings that can be uniquely and
reversibly stored as 32bit integer numbers but also any string of digits
that will represent/contain a 32 bit number like "01", "0800555123",
"00" or "0000" to just list a few.
to fix this I replaced the match with the following:
m/^[\-+]?(0|[1-9]\d*)$/
which should fix this problem.
For the sake of simplicity: here the complete patched function.
sub parse_scalar {
my $self = shift;
my $scalar = shift;
local $^W = undef;
if ( ( $scalar =~ m/^[\-+]?(0|[1-9]\d*)$/ )
&& ( abs($scalar) <= ( 0xffffffff >> 1 ) ) )
{
return { i4 => $scalar };
}
elsif ( $scalar =~ m/^[\-+]?\d+\.\d+$/ ) {
return { double => $scalar };
}
else {
return { string => \$scalar };
}
}
Please update in your next release, I do not claim any rights on this
code, please distribute freely!