Browse Source

Dpkg::Control::HashCore: Only skip actual empty first line field values

Regression introduced in commit c2ee90f92ab6c915db774403414b2ea70c967c3e.

We need to check if the value is empty, not if it's false. Add a
regression test.
Guillem Jover 12 years ago
parent
commit
397448b748
3 changed files with 5 additions and 2 deletions
  1. 1 1
      scripts/Dpkg/Control/HashCore.pm
  2. 3 1
      scripts/t/Dpkg_Control.t
  3. 1 0
      scripts/t/Dpkg_Control/control-1

+ 1 - 1
scripts/Dpkg/Control/HashCore.pm

@@ -352,7 +352,7 @@ sub output {
 	    my ($first_line, @lines) = split /\n/, $value;
 
 	    my $kv = "$key:";
-	    $kv .= ' ' . $first_line if $first_line;
+	    $kv .= ' ' . $first_line if length $first_line;
 	    $kv .= "\n";
 	    foreach (@lines) {
 		s/\s+$//;

+ 3 - 1
scripts/t/Dpkg_Control.t

@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 22;
+use Test::More tests => 23;
 use IO::String;
 
 BEGIN {
@@ -45,6 +45,7 @@ my $io = IO::String->new();
 $c->output($io);
 my $value = ${$io->string_ref()};
 my $expected = 'Source: mysource
+Numeric-Field: 0
 My-Field-One: myvalue1
 My-Field-Two: myvalue2
 Long-Field: line1
@@ -74,6 +75,7 @@ is($value, $expected, "Dump of $datadir/control-1");
 
 my $src = $c->get_source();
 is($src, $c->[0], 'array representation of Dpkg::Control::Info 1/2');
+is($src->{'numeric-field'}, '0', 'Numeric 0 value parsed correctly');
 is($src->{'my-field-one'}, 'myvalue1', 'Access field through badly capitalized field name');
 is($src->{'long-field'},
 'line1

+ 1 - 0
scripts/t/Dpkg_Control/control-1

@@ -1,5 +1,6 @@
 Source: mysource
 # This is a comment
+numeric-field: 0
 my-field-one: myvalue1
 my-field-two: myvalue2
 long-field: line1