Browse Source

Dpkg::Changelog::Entry::Debian: Do not abort on Time::Piece parse errors

The Date::Parse str2time() function returns undef on parse errors, but
Time::Piece strptime() aborts, so to preserve the previous behavior we
need to trap any such errors, and handle them ourselves, as the caller
might want to warn instead.

Closes: #795936
Guillem Jover 11 years ago
parent
commit
f2471e8f41
2 changed files with 8 additions and 3 deletions
  1. 3 0
      debian/changelog
  2. 5 3
      scripts/Dpkg/Changelog/Entry/Debian.pm

+ 3 - 0
debian/changelog

@@ -18,6 +18,9 @@ dpkg (1.18.3) UNRELEASED; urgency=low
       Reported by Jakub Wilk <jwilk@debian.org>.
     - Do not warn when removing an empty subdirectory on source package
       extraction in Dpkg::Source::Package::V2. Closes: #796671
+    - Do not abort on parse errors from Time::Piece->strptime() for the
+      changelog trailer date, just queue them so that the caller can decide
+      if they should be warnings or actual errors. Closes: #795936
   * Test suite:
     - Get the reference build flags from dpkg-buildflags.pl, instead of
       hardcoding them, which might not match depending on the architecture.

+ 5 - 3
scripts/Dpkg/Changelog/Entry/Debian.pm

@@ -175,9 +175,11 @@ sub check_trailer {
 
 	# Ignore the week day ('%a, '), as we have validated it above.
 	local $ENV{LC_ALL} = 'C';
-	unless (defined Time::Piece->strptime($7, '%d %b %Y %T %z')) {
-	    push @errors, sprintf(g_("couldn't parse date %s"), $4);
-	}
+	eval {
+	    Time::Piece->strptime($7, '%d %b %Y %T %z');
+	} or do {
+	    push @errors, sprintf(g_("cannot parse non-comformant date '%s'"), $7);
+	};
     } else {
 	push @errors, g_("the trailer doesn't match the expected regex");
     }