Browse Source

Dpkg::Changelog::Entry::Debian: Fix parse error message when date is on May

When a broken date is on May the error message ended up being very
confusing as it mentioned that it was using a full instead of an
abbreviated month name, because for May both are the same.

Nest the conditionals to avoid this problem.

Closes: #843829
Signed-off-by: Guillem Jover <guillem@debian.org>
Nishanth Aravamudan 7 years ago
parent
commit
e20aeeaf59
2 changed files with 13 additions and 5 deletions
  1. 4 0
      debian/changelog
  2. 9 5
      scripts/Dpkg/Changelog/Entry/Debian.pm

+ 4 - 0
debian/changelog

@@ -12,6 +12,10 @@ dpkg (1.18.14) UNRELEASED; urgency=medium
     some cases segfaults when reporting the error summary at the end.
     Regression introduced in dpkg 1.18.11. Closes: #843874
   * Change default color behavior to auto.
+  * Perl modules:
+    - Fix confusing date parse error message in Dpkg::Changelog::Entry::Debian
+      when the date contains “May”. Closes: #843829
+      Thanks to Nishanth Aravamudan <nish.aravamudan@canonical.com>.
   * Test suite:
     - Do not fail tests on missing fakeroot, just skip them.
   * Build system:

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

@@ -226,11 +226,15 @@ sub parse_trailer {
 	    # Validate the month. Date::Parse used to accept both abbreviated
 	    # and full months, but Time::Piece strptime() implementation only
 	    # matches the abbreviated one with %b, which is what we want anyway.
-	    if (exists $month_name{$8}) {
-	        push @errors, sprintf(g_('uses full instead of abbreviated month name \'%s\''),
-	                              $8, $month_name{$8});
-	    } elsif (not exists $month_abbrev{$8}) {
-	        push @errors, sprintf(g_('invalid abbreviated month name \'%s\''), $8);
+	    if (not exists $month_abbrev{$8}) {
+	        # We have to nest the conditionals because May is the same in
+	        # full and abbreviated forms!
+	        if (exists $month_name{$8}) {
+	            push @errors, sprintf(g_('uses full instead of abbreviated month name \'%s\''),
+	                                  $8, $month_name{$8});
+	        } else {
+	            push @errors, sprintf(g_('invalid abbreviated month name \'%s\''), $8);
+	        }
 	    }
 	    push @errors, sprintf(g_("cannot parse non-comformant date '%s'"), $7);
 	};