Fix APKBUILD attribute parsing when opening quote is followed by line break (#415)

his adds a check to continue attribute parsing when end_char is found
in the end of first line, but is present only once. Found in gtk+2.0 APKBUILD:
https://git.alpinelinux.org/cgit/aports/plain/main/gtk+2.0/APKBUILD
This commit is contained in:
NotKit 2017-08-19 04:15:28 +03:00 committed by Oliver Smith
parent 795d41e058
commit 689eb5c3c9
1 changed files with 6 additions and 1 deletions

View File

@ -112,10 +112,15 @@ def apkbuild(args, path):
if line_value.startswith("\""):
end_char = "\""
value = ""
first_line = i
while i < len(lines) - 1:
value += line_value.replace("\"", "").strip()
if not end_char or line_value.endswith(end_char):
if not end_char:
break
elif line_value.endswith(end_char):
# This check is needed to allow line break directly after opening quote
if i != first_line or line_value.count(end_char) > 1:
break
value += " "
i += 1
line_value = lines[i][:-1]