Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 111155
Status: resolved
Priority: 0/
Queue: DateTime-Format-Strptime

People
Owner: Nobody in particular
Requestors: ilmari+cpan [...] ilmari.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.58-TRIAL
  • 1.59-TRIAL
  • 1.60
  • 1.61
  • 1.62
Fixed in: 1.63



Subject: No longer accepts trailing text
After the rewrite in 1.57, parse_datetime no longer accepts traling text after the part that matched the pattern. Before: $ perl -MDateTime::Format::Strptime -E 'say DateTime::Format::Strptime->VERSION; say DateTime::Format::Strptime->new(pattern=>"%Y-%m-%d", on_error=>"croak")->parse_datetime("2016-01-13 and a bit")' 1.57 2016-01-13T00:00:00 After: $ perl -MDateTime::Format::Strptime -E 'say DateTime::Format::Strptime->VERSION; say DateTime::Format::Strptime->new(pattern=>"%Y-%m-%d", on_error=>"croak")->parse_datetime("2016-01-13 and a bit")' 1.62 Your datetime does not match your pattern. at -e line 1.
On 2016-01-13 17:22:59, ilmari wrote: Show quoted text
> After the rewrite in 1.57, parse_datetime no longer accepts traling > text after the part that matched the pattern.
The attached patch restores the old behaviour.
Subject: 0001-Ignore-traling-text-after-match.patch
From e2db597c27aa37e3bb193453b77ce7e41dab74af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Ilmari=20Manns=C3=A5ker?= <ilmari.mannsaker@net-a-porter.com> Date: Wed, 13 Jan 2016 17:47:34 +0000 Subject: [PATCH] Ignore traling text after match This behaviour was lost in the rewrite, which caused it to only accept trailing whitespace. --- Changes | 6 ++++++ lib/DateTime/Format/Strptime.pm | 2 +- t/edge.t | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index e4fe0eb..48aaf92 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ {{$NEXT}} +[BUG FIXES] + +- The behaviour of silently ignoring text after the matching part was + lost in the rewrite. This has been restored. Patch by Dagfinn Ilmari + Mannsåker. RT #111155. + 1.62 2015-12-19 [BUG FIXES] diff --git a/lib/DateTime/Format/Strptime.pm b/lib/DateTime/Format/Strptime.pm index 88054d2..e2ed0c5 100644 --- a/lib/DateTime/Format/Strptime.pm +++ b/lib/DateTime/Format/Strptime.pm @@ -317,7 +317,7 @@ sub _build_parser { } return { - regex => qr/\A\s*$regex\s*\z/, + regex => qr/\A\s*$regex/, fields => \@fields, }; } diff --git a/t/edge.t b/t/edge.t index 5b3708a..ab809d6 100644 --- a/t/edge.t +++ b/t/edge.t @@ -52,3 +52,11 @@ year => 2007 month => 8 day => 15 + +[Trailing text after match] +%Y-%m-%d +2016-01-13 in the afternoon +skip round trip +year => 2016 +month => 1 +day => 13 -- 2.7.0.rc3