Skip to content

Commit

Permalink
Merge 14dfc00 into 36a2439
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovid committed Oct 28, 2016
2 parents 36a2439 + 14dfc00 commit fe4701c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Changes for Perl extension DateTime-Tiny

{{$NEXT}}

1.07
- Bugfix: only match ASCII digits in from_string() method.

1.06 2016-06-23 09:43:41-04:00 America/New_York
- No changes from 1.05

Expand Down
3 changes: 2 additions & 1 deletion lib/DateTime/Tiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ sub from_string {
require Carp;
Carp::croak("Did not provide a string to from_string");
}
unless ( $string =~ /^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)$/ ) {
my $d = '[0-9]'; # backwards-compatible way of not matching anything but ASCII digits
unless ( $string =~ /^($d$d$d$d)-($d$d)-($d$d)T($d$d):($d$d):($d$d)$/ ) {
require Carp;
Carp::croak("Invalid time format (does not match ISO 8601)");
}
Expand Down
10 changes: 9 additions & 1 deletion t/02_main.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ BEGIN {
$^W = 1;
}

use Test::More tests => 31;
use Test::More tests => 32;
use DateTime::Tiny;
use utf8;



Expand Down Expand Up @@ -114,3 +115,10 @@ SCOPE: {
$tiny, '->from_string ok',
);
}

SCOPE: {
eval { DateTime::Tiny->from_string('୭୮୯௦-௧௨-௩௪T௫௬:௭௮:௯౦') };
my $error = $@;
like $error, qr/\QInvalid time format (does not match ISO 8601)/,
'Only ASCII digits are valid in datetime strings';
}

0 comments on commit fe4701c

Please sign in to comment.