Browse Source

Dpkg: Relax dependency restriction parsing to allow sloppy spaces

Allow sloppy spaces again around versions, architectures and profile
restrictions, so that we do not fail on previously accepted dependencies.

Regression introduced in commit bd17966babf8705e8f02c808f646dfa149828256.

Closes: #823431
Reported-by: Niko Tyni <ntyni@debian.org>
Guillem Jover 8 years ago
parent
commit
a234261b4e
4 changed files with 20 additions and 4 deletions
  1. 4 0
      debian/changelog
  2. 2 2
      scripts/Dpkg/BuildProfiles.pm
  3. 1 1
      scripts/Dpkg/Deps.pm
  4. 13 1
      scripts/t/Dpkg_Deps.t

+ 4 - 0
debian/changelog

@@ -1,6 +1,10 @@
 dpkg (1.18.7) UNRELEASED; urgency=medium
 
   [ Guillem Jover ]
+  * Perl modules:
+    - Relax dependency restrictions parsing to allow again sloppy spaces
+      around versions, architectures and profile restrictions.
+      Regression introduced in 1.18.5. Closes: #823431
   * Documentation:
     - Shorten example symbol names in dpkg-gensymbols to avoid a mandb
       warning due to unwrappable lines in translations.

+ 2 - 2
scripts/Dpkg/BuildProfiles.pm

@@ -91,9 +91,9 @@ Parses a build profiles specification, into an array of array references.
 sub parse_build_profiles {
     my $string = shift;
 
-    $string =~ s/^\s*<(.*)>\s*$/$1/;
+    $string =~ s/^\s*<\s*(.*)\s*>\s*$/$1/;
 
-    return map { [ split /\s+/ ] } split />\s+</, $string;
+    return map { [ split /\s+/ ] } split /\s*>\s+<\s*/, $string;
 }
 
 =item evaluate_restriction_formula(\@formula, \@profiles)

+ 1 - 1
scripts/Dpkg/Deps.pm

@@ -602,7 +602,7 @@ sub parse_string {
               (?:                           # start of optional part
                 \s* \(                      # open parenthesis for version part
                 \s* (<<|<=|=|>=|>>|[<>])    # relation part
-                \s* ([^\)]+)                # do not attempt to parse version
+                \s* ([^\)\s]+)              # do not attempt to parse version
                 \s* \)                      # closing parenthesis
               )?                            # end of optional part
               (?:                           # start of optional architecture

+ 13 - 1
scripts/t/Dpkg_Deps.t

@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 47;
+use Test::More tests => 50;
 
 use Dpkg::Arch qw(get_host_arch);
 use Dpkg::Version;
@@ -188,6 +188,18 @@ is($dep_empty1->output(), '', 'Empty dependency');
 my $dep_empty2 = deps_parse(' , , ', union => 1);
 is($dep_empty2->output(), '', "' , , ' is also an empty dependency");
 
+# Check sloppy but acceptable dependencies
+
+my $dep_sloppy_version = deps_parse('package (=   1.0  )');
+is($dep_sloppy_version->output(), 'package (= 1.0)', 'sloppy version restriction');
+
+my $dep_sloppy_arch = deps_parse('package [  alpha    ]');
+is($dep_sloppy_arch->output(), 'package [alpha]', 'sloppy arch restriction');
+
+my $dep_sloppy_profile = deps_parse('package <  !profile    >   <  other  >');
+is($dep_sloppy_profile->output(), 'package <!profile> <other>',
+   'sloppy profile restriction');
+
 $SIG{__WARN__} = sub {};
 
 my $dep_bad_version = deps_parse('package (= 1.0) (>= 2.0)');