This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=cf3f7151de62b69ae4f821c165d0697109c912ac

commit cf3f7151de62b69ae4f821c165d0697109c912ac
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Jun 2 01:55:10 2020 +0200

    dpkg-parsechangelog: Fix --show-field for multiline fields
    
    We were not stripping trailing whitespace, and were not prefixing
    empty lines with a ‘.’, like when printing with the field names.
    
    Reported-by: Paul Wise <[email protected]>
---
 debian/changelog               |  4 ++++
 scripts/dpkg-parsechangelog.pl | 17 ++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 54ac69405..0c1806144 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,10 @@ dpkg (1.20.1) UNRELEASED; urgency=medium
     be uninitialized.
   * update-alternatives: Set the umask to 022 on program start.
     Reported by Paul Wise <[email protected]>.
+  * dpkg-parsechangelog: Fix --show-field for multiline fields. We were not
+    stripping trailing whitespace, and were not prefixing empty lines with
+    a ‘.’, like when printing with the field names.
+    Reported by Paul Wise <[email protected]>.
   * Portability:
     - libdpkg: When using uselocale(), include <xlocale.h> for locale_t if
       the header is available. Needed on BSDs.
diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl
index 3d14c4219..69700958d 100755
--- a/scripts/dpkg-parsechangelog.pl
+++ b/scripts/dpkg-parsechangelog.pl
@@ -128,7 +128,22 @@ my @fields = changelog_parse(%options);
 foreach my $f (@fields) {
     print "\n" if $count++;
     if ($fieldname) {
-        print $f->{$fieldname} . "\n" if exists $f->{$fieldname};
+        next if not exists $f->{$fieldname};
+
+        my ($first_line, @lines) = split /\n/, $f->{$fieldname};
+
+        my $v = '';
+        $v .= $first_line if length $first_line;
+        $v .= "\n";
+        foreach (@lines) {
+            s/\s+$//;
+            if (length == 0 or /^\.+$/) {
+                $v .= ".$_\n";
+            } else {
+                $v .= "$_\n";
+            }
+        }
+        print $v;
     } else {
         print $f->output();
     }

-- 
Dpkg.Org's dpkg

Reply via email to