chiark / gitweb /
update: handle bad XML when using androguard
authorHans-Christoph Steiner <hans@eds.org>
Sun, 11 Mar 2018 21:10:46 +0000 (22:10 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 12 Mar 2018 16:55:45 +0000 (17:55 +0100)
repo/ch.swift.willi_417101.apk had a C/Java comment in the
AndroidManifest.xml rather than an XML comment:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26">
</uses-sdk>
// Remove permissions introduced by the appsflyer library
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION">
</uses-permission>

fdroidserver/update.py

index 168ef31f4195310cc8ce8d7a5ee7b8f937e44207..7203fbcc2a360d9f2ecb6dc1a730d96cbd7acd9b 100644 (file)
@@ -1264,7 +1264,10 @@ def scan_apk_androguard(apk, apkfile):
         apk['uses-permission-sdk-23'].append(permission_sdk_23)
 
     for item in xml.findall('uses-feature'):
-        feature = str(item.attrib['{' + xml.nsmap['android'] + '}name'])
+        key = '{' + xml.nsmap['android'] + '}name'
+        if key not in item.attrib:
+            continue
+        feature = str(item.attrib[key])
         if feature != "android.hardware.screen.portrait" \
                 and feature != "android.hardware.screen.landscape":
             if feature.startswith("android.feature."):