Skip to content

Commit

Permalink
Allow superfluous commas in build-dependency lines
Browse files Browse the repository at this point in the history
This code can interact with handwritten files who can have unneeded
commas for writing easy. As dpkg allows it, we should do as well.

Reported-By: Arnaud Ferraris <arnaud.ferraris@gmail.com>
References: https://lists.debian.org/debian-devel/2021/03/msg00101.html
  • Loading branch information
DonKult committed Apr 25, 2021
1 parent 25e11a6 commit d7e3d28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions apt-pkg/deb/debsrcrecords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe

while (1)
{
// Strip off leading spaces (is done by ParseDepends, too) and
// superfluous commas (encountered in user-written dsc/control files)
do {
for (;Start != Stop && isspace_ascii(*Start) != 0; ++Start);
} while (*Start == ',' && ++Start != Stop);
if (Start == Stop)
break;

BuildDepRec rec;
Start = debListParser::ParseDepends(Start, Stop,
rec.Package, rec.Version, rec.Op, true, StripMultiArch, true);
Expand All @@ -141,9 +149,6 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
} else {
BuildDeps.emplace_back(std::move(rec));
}

if (Start == Stop)
break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/integration/test-apt-get-build-dep-file
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ Source: apturl
Section: admin
Priority: optional
Maintainer: Michael Vogt <mvo@ubuntu.com>
Build-Depends: debhelper (>= 7)
Build-Depends: ,debhelper (>= 7),
Build-Conflicts: ,,,
Build-Depends-Indep:
X-Python3-Version: >= 3.2
Standards-Version: 3.9.3
Expand Down

0 comments on commit d7e3d28

Please sign in to comment.