Prechádzať zdrojové kódy

Dpkg::Dist::Files: Allow colons (:) in added filenames

Regression introduced in commit ab15fd24dd1a8207ab1463410338f24283989f7c.

Packages can contain colons in their filenames if the upstream version
contains colons.

Reported-by: Jakub Wilk <jwilk@debian.org>
Guillem Jover 11 rokov pred
rodič
commit
354bdeeee0
3 zmenil súbory, kde vykonal 31 pridanie a 18 odobranie
  1. 3 0
      debian/changelog
  2. 2 2
      scripts/Dpkg/Dist/Files.pm
  3. 26 16
      scripts/t/Dpkg_Dist_Files.t

+ 3 - 0
debian/changelog

@@ -26,6 +26,9 @@ dpkg (1.18.2) UNRELEASED; urgency=low
     - Disable the thread sanitizer when the address sanitizer is enabled
       in Dpkg::Vendor::Debian as these are mutually incompatible, and make
       sanitize=+all not work at all.
+    - Allow colons (:) in added filenames in Dpkg::Dist::Files, which can be
+      present when the upstream version contains colons. Regression introduced
+      in dpkg 1.18.0. Reported by Jakub Wilk <jwilk@debian.org>.
   * Documentation:
     - Fix grammar in dpkg-architecture(1).
       Thanks to Chris Lamb <lamby@debian.org>. Closes: #787616

+ 2 - 2
scripts/Dpkg/Dist/Files.pm

@@ -52,13 +52,13 @@ sub parse_filename {
 
     my $file;
 
-    if ($fn =~ m/^(([-+.0-9a-z]+)_([^_]+)_([-\w]+)\.([a-z0-9.]+))$/) {
+    if ($fn =~ m/^(([-+:.0-9a-z]+)_([^_]+)_([-\w]+)\.([a-z0-9.]+))$/) {
         $file->{filename} = $1;
         $file->{package} = $2;
         $file->{version} = $3;
         $file->{arch} = $4;
         $file->{package_type} = $5;
-    } elsif ($fn =~ m/^([-+.,_0-9a-zA-Z~]+)$/) {
+    } elsif ($fn =~ m/^([-+:.,_0-9a-zA-Z~]+)$/) {
         $file->{filename} = $1;
     } else {
         $file = undef;

+ 26 - 16
scripts/t/Dpkg_Dist_Files.t

@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 23;
+use Test::More tests => 24;
 
 use_ok('Dpkg::Dist::Files');
 
@@ -25,13 +25,13 @@ my $datadir = $srcdir . '/t/Dpkg_Dist_Files';
 
 my $expected;
 my %expected = (
-    'pkg-src_2.0+1A~rc1-1.dsc' => {
-        filename => 'pkg-src_2.0+1A~rc1-1.dsc',
+    'pkg-src_4:2.0+1A~rc1-1.dsc' => {
+        filename => 'pkg-src_4:2.0+1A~rc1-1.dsc',
         section => 'source',
         priority => 'extra',
     },
-    'pkg-src_2.0+1A~rc1-1.tar.xz' => {
-        filename => 'pkg-src_2.0+1A~rc1-1.tar.xz',
+    'pkg-src_4:2.0+1A~rc1-1.tar.xz' => {
+        filename => 'pkg-src_4:2.0+1A~rc1-1.tar.xz',
         section => 'source',
         priority => 'extra',
     },
@@ -72,6 +72,11 @@ my %expected = (
         section => 'webdocs',
         priority => 'optional',
     },
+    'another:filename' => {
+        filename => 'another:filename',
+        section => 'by-hand',
+        priority => 'extra',
+    },
     'added-on-the-fly' => {
         filename => 'added-on-the-fly',
         section => 'void',
@@ -127,20 +132,25 @@ is($dist->get_file('pkg-indep_0.0.1-2_all.deb'), undef, 'Get deleted file');
 is($dist->output(), $expected, 'Modified dist object');
 
 $expected = <<'FILES';
-pkg-src_2.0+1A~rc1-1.dsc source extra
-pkg-src_2.0+1A~rc1-1.tar.xz source extra
+another:filename by-hand extra
+pkg-src_4:2.0+1A~rc1-1.dsc source extra
+pkg-src_4:2.0+1A~rc1-1.tar.xz source extra
 FILES
 
 $dist->reset();
-$dist->add_file('pkg-src_2.0+1A~rc1-1.dsc', 'source', 'extra');
-$dist->add_file('pkg-src_2.0+1A~rc1-1.tar.xz', 'source', 'extra');
-
-is_deeply($dist->get_file('pkg-src_2.0+1A~rc1-1.dsc'),
-          $expected{'pkg-src_2.0+1A~rc1-1.dsc'},
-          'Get added file pkg-src_2.0+1A~rc1-1.dsc');
-is_deeply($dist->get_file('pkg-src_2.0+1A~rc1-1.tar.xz'),
-          $expected{'pkg-src_2.0+1A~rc1-1.tar.xz'},
-          'Get added file pkg-src_2.0+1A~rc1-1.tar.xz');
+$dist->add_file('pkg-src_4:2.0+1A~rc1-1.dsc', 'source', 'extra');
+$dist->add_file('pkg-src_4:2.0+1A~rc1-1.tar.xz', 'source', 'extra');
+$dist->add_file('another:filename', 'by-hand', 'extra');
+
+is_deeply($dist->get_file('pkg-src_4:2.0+1A~rc1-1.dsc'),
+          $expected{'pkg-src_4:2.0+1A~rc1-1.dsc'},
+          'Get added file pkg-src_4:2.0+1A~rc1-1.dsc');
+is_deeply($dist->get_file('pkg-src_4:2.0+1A~rc1-1.tar.xz'),
+          $expected{'pkg-src_4:2.0+1A~rc1-1.tar.xz'},
+          'Get added file pkg-src_4:2.0+1A~rc1-1.tar.xz');
+is_deeply($dist->get_file('another:filename'),
+          $expected{'another:filename'},
+          'Get added file another:filename');
 is($dist->output, $expected, 'Added source files');
 
 $expected = <<'FILES';