From fa09337b4b177f8e666043ef861215b46dc22ad5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 18 Sep 2018 15:20:37 +0200 Subject: [PATCH] APK_ID_TRIPLET_REGEX only matches first line of aapt output Stop expensive aapt parsing after the first line when looking with APK_ID_TRIPLET_REGEX. As is seen with the `aapt dump badging` output files in tests/build-tools/, the first line is the only line that will ever match. #557 --- fdroidserver/common.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index cedc8c5a..7b8842a1 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -2120,10 +2120,9 @@ def get_apk_id_androguard(apkfile): def get_apk_id_aapt(apkfile): p = SdkToolsPopen(['aapt', 'dump', 'badging', apkfile], output=False) - for line in p.output.splitlines(): - m = APK_ID_TRIPLET_REGEX.match(line) - if m: - return m.group(1), m.group(2), m.group(3) + m = APK_ID_TRIPLET_REGEX.match(p.output[0:p.output.index('\n')]) + if m: + return m.group(1), m.group(2), m.group(3) raise FDroidException(_("Reading packageName/versionCode/versionName failed, APK invalid: '{apkfilename}'") .format(apkfilename=apkfile))