summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-08-05 21:27:41 +0200
committerGuillem Jover <guillem@debian.org>2015-08-06 04:12:24 +0200
commitafef8fbf76e4d87ea8ab824370507f5017a4818e (patch)
treeb0bf60e8767d8724de8d85140bbe15d94428835e /scripts
parentbacb47ef2cee950c9c167b9cb6a95ecd0a051634 (diff)
downloaddpkg-afef8fbf76e4d87ea8ab824370507f5017a4818e.tar.gz
Dpkg::Changelog::Entry::Debian: Only warn on invalid week days
Regression introduced in commit 7a71b4b78e8a81158c45073dee05b0d1cc46b71c. The previous implementation using Date::Parse ignored invalid week days, and the new one using Time::Piece is strict, so we get fatal errors. Validate the week day ourselves, emit a warning in case of an invalid value, and ignore it when passing the value to strptime from Time::Piece. Reported-by: Jakub Wilk <jwilk@debian.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Dpkg/Changelog/Entry/Debian.pm15
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm
index e1d0b33ee..d81391277 100644
--- a/scripts/Dpkg/Changelog/Entry/Debian.pm
+++ b/scripts/Dpkg/Changelog/Entry/Debian.pm
@@ -64,7 +64,9 @@ our $regex_header = qr/^(\w$name_chars*) \(([^\(\) \t]+)\)((?:\s+$name_chars+)+)
# The matched content is the maintainer name ($1), its email ($2),
# some blanks ($3) and the timestamp ($4).
-our $regex_trailer = qr/^ \-\- (.*) <(.*)>( ?)((\w+\,\s*)?\d{1,2}\s+\w+\s+\d{4}\s+\d{1,2}:\d\d:\d\d\s+[-+]\d{4})\s*$/o;
+our $regex_trailer = qr/^ \-\- (.*) <(.*)>( ?)(((\w+)\,\s*)?(\d{1,2}\s+\w+\s+\d{4}\s+\d{1,2}:\d\d:\d\d\s+[-+]\d{4}))\s*$/o;
+
+my %week_day = map { $_ => 1 } qw(Mon Tue Wed Thu Fri Sat Sun);
## use critic
@@ -165,12 +167,15 @@ sub check_trailer {
push @errors, g_('badly formatted trailer line');
}
- my $fmt = '';
- $fmt .= '%a, ' if defined $5;
- $fmt .= '%d %b %Y %T %z';
+ # Validate the week day. Date::Parse used to ignore it, but Time::Piece
+ # is much more strict and it does not gracefully handle bogus values.
+ if (defined $5 and not exists $week_day{$6}) {
+ push @errors, sprintf(g_('ignoring invalid week day \'%s\''), $6);
+ }
+ # Ignore the week day ('%a, '), as we have validated it above.
local $ENV{LC_ALL} = 'C';
- unless (defined Time::Piece->strptime($4, $fmt)) {
+ unless (defined Time::Piece->strptime($7, '%d %b %Y %T %z')) {
push @errors, sprintf(g_("couldn't parse date %s"), $4);
}
} else {