Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] portage.manifest: Fix mis-parsing Manifests with numerical checksums
Date: Sun, 19 Nov 2017 17:12:34
Message-Id: 20171119171223.24472-1-mgorny@gentoo.org
1 Fix the regular expression used to parse Manifests not to fail horribly
2 when one of the checksums accidentally happens to be all-digits.
3
4 The previously used regular expression used to greedily take everything
5 up to the first number as filename. If one of the checksums happened to
6 be purely numeric, this meant that everything up to that checksum was
7 taken as filename, and the checksum itself was taken as file size. It
8 was also capable of accepting an empty filename.
9
10 The updated regular expression uses '\S+' to match filenames. Therefore,
11 the match is terminated on first whitespace character and filenames can
12 no longer contain spaces. Not that it could ever work reliably.
13
14 Spotted by Ulrich Müller.
15
16 Bug: https://bugs.gentoo.org/638148
17 ---
18 pym/portage/manifest.py | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21 diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
22 index 4ec20515e..4bca61e86 100644
23 --- a/pym/portage/manifest.py
24 +++ b/pym/portage/manifest.py
25 @@ -30,7 +30,7 @@ from portage.const import (MANIFEST2_HASH_DEFAULTS, MANIFEST2_IDENTIFIERS)
26 from portage.localization import _
27
28 _manifest_re = re.compile(
29 - r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (.*)( \d+( \S+ \S+)+)$',
30 + r'^(' + '|'.join(MANIFEST2_IDENTIFIERS) + r') (\S+)( \d+( \S+ \S+)+)$',
31 re.UNICODE)
32
33 if sys.hexversion >= 0x3000000:
34 --
35 2.15.0

Replies