pmb.parse.parse_attribute: strip off trailing comment on attrib line (MR 2149)

The apkbuild parser could not handle cases where a line ends in a
comment but the value is not quoted.

E.g. this:

    pkgver=1.0 # I'm a comment, look at me

was being parsed to a value like this:

    1.0 # I'm a comment, look at me

... which is obviously wrong. This strips off any trailing comment on
the line, so it's parsed to the correct value.

fixes #2087
This commit is contained in:
Clayton Craft 2021-12-12 01:00:32 -08:00 committed by Alexey Min
parent 672ebe797b
commit 58e4e86b6b
No known key found for this signature in database
GPG Key ID: 0B19D2A65870B448
1 changed files with 1 additions and 0 deletions

View File

@ -159,6 +159,7 @@ def parse_attribute(attribute, lines, i, path):
# Single line
if not end_char:
value = value.split("#")[0].rstrip()
return (True, value, i)
if end_char in value:
value = value.split(end_char, 1)[0]