The following commit has been merged in the master branch:
commit fe930e9bb3e195825cce98e4abe825459a7e81e7
Author: Raphael Hertzog <[email protected]>
Date: Thu Jun 25 21:43:29 2009 +0200
Dpkg::Deps: fix dependency parsing code
Fix dependency parsing code in Dpkg::Deps to not accept "foo\nbar"
even if foo is valid. A regex was improperly matching "\n" as
end of string due to usage of the "m" modifier.
Also improve the warning displayed when the dependency can't be parsed.
Add a non-regression test to ensure that this problem doesn't come back.
Reported-by: Andrew Sayers <[email protected]>
diff --git a/debian/changelog b/debian/changelog
index 0f4a079..a0866d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -40,6 +40,9 @@ dpkg (1.15.3) UNRELEASED; urgency=low
(recognized by ~bpo or ~vola in their version number). Closes: #525115
* Support all checksum algorithms in dpkg-scanpackages/dpkg-scansources.
Closes: #533828
+ * Fix dependency parsing code in Dpkg::Deps to not accept "foo\nbar"
+ even if foo is valid. Closes: #534464
+ Thanks to Andrew Sayers for spotting the problem.
[ Joachim Breitner ]
* Warn about unused substvars in dpkg-gencontrol. Closes: #532760
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 89a1e10..b30adb7 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -317,7 +317,7 @@ sub parse {
foreach my $dep_or (split(/\s*\|\s*/m, $dep_and)) {
my $dep_simple = Dpkg::Deps::Simple->new($dep_or);
if (not defined $dep_simple->{package}) {
- warning(_g("can't parse dependency %s"), $dep_and);
+ warning(_g("can't parse dependency %s"), $dep_or);
return undef;
}
$dep_simple->{arches} = undef if not $options{use_arch};
@@ -555,7 +555,7 @@ sub parse {
\s* \] # closing bracket
)? # end of optional architecture
\s*$ # trailing spaces at end
- /mx;
+ /x;
$self->{package} = $1;
$self->{relation} = $2;
$self->{version} = $3;
diff --git a/scripts/t/400_Dpkg_Deps.t b/scripts/t/400_Dpkg_Deps.t
index 8490c16..1415515 100644
--- a/scripts/t/400_Dpkg_Deps.t
+++ b/scripts/t/400_Dpkg_Deps.t
@@ -1,6 +1,6 @@
# -*- mode: cperl;-*-
-use Test::More tests => 15;
+use Test::More tests => 16;
use strict;
use warnings;
@@ -63,3 +63,8 @@ is($dep_empty1->dump(), "", "Empty dependency");
my $dep_empty2 = Dpkg::Deps::parse(" , , ", union => 1);
is($dep_empty2->dump(), "", "' , , ' is also an empty dependency");
+$SIG{'__WARN__'} = sub {};
+my $dep_bad_multiline = Dpkg::Deps::parse("a, foo\nbar, c");
+ok(!defined($dep_bad_multiline), "invalid dependency split over multiple
line");
+delete $SIG{'__WARN__'};
+
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]