Skip Menu |

This queue is for tickets about the DateTime-Format-Duration-ISO8601 CPAN distribution.

Report information
The Basics
Id: 122682
Status: resolved
Priority: 0/
Queue: DateTime-Format-Duration-ISO8601

People
Owner: Nobody in particular
Requestors: pipcet [...] gmail.com
Cc:
AdminCc:

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



Subject: parse PT0S
Date: Wed, 2 Aug 2017 06:53:46 +0000
To: bug-DateTime-Format-Duration-ISO8601 [...] rt.cpan.org
From: Pip Cet <pipcet [...] gmail.com>
Hi, I'm using your DateTime::Format::Duration::ISO8601 in a project, and have run into the following bug: $ perl -MDateTime::Duration -MDateTime::Format::Duration::ISO8601 -e 'DateTime::Format::Duration::ISO8601->parse_duration("PT0S")' Can't use string ("DateTime::Format::Duration::ISO8"...) as a HASH ref while "strict refs" in use at /home/pip/perl5/lib/perl5/DateTime/Format/Duration/ISO8601.pm line 141, <DATA> line 1. There are at least two things wrong here: the first bug is that the main regexp has (?:(?<seconds>[0-9]+(?:\.([0-9]+)?))S)? but should have (?:(?<seconds>[0-9]+(?:\.([0-9]+))?)S)? or (?:(?<seconds>[0-9]+(?:\.([0-9]+)?)?)S)? The second bug is that _error doesn't check that $self is indeed a reference (not a package name) before dereferencing $self->{ on_error }. I would also suggest to die in this case rather than returning silently. I've put both changes in the single patch I've attached, but they should be easy to isolate. Thanks, Pip Cet

Message body is not shown because sender requested not to inline it.

Thanks for the patch, applied and released 0.005. Regards, perlancar On Wed, 2 Aug 2017 06:54:39 GMT, pipcet@gmail.com wrote: Show quoted text
> Hi, > I'm using your DateTime::Format::Duration::ISO8601 in a project, and > have run into the following bug: > > $ perl -MDateTime::Duration -MDateTime::Format::Duration::ISO8601 -e > 'DateTime::Format::Duration::ISO8601->parse_duration("PT0S")' > Can't use string ("DateTime::Format::Duration::ISO8"...) as a HASH ref > while "strict refs" in use at > /home/pip/perl5/lib/perl5/DateTime/Format/Duration/ISO8601.pm line > 141, <DATA> line 1. > > There are at least two things wrong here: the first bug is that the > main regexp has > > (?:(?<seconds>[0-9]+(?:\.([0-9]+)?))S)? > > but should have > > (?:(?<seconds>[0-9]+(?:\.([0-9]+))?)S)? > > or > > (?:(?<seconds>[0-9]+(?:\.([0-9]+)?)?)S)? > > The second bug is that _error doesn't check that $self is indeed a > reference (not a package name) before dereferencing $self->{ on_error > }. I would also suggest to die in this case rather than returning > silently. > > I've put both changes in the single patch I've attached, but they > should be easy to isolate. > > Thanks, > Pip Cet