chiark / gitweb /
Handle with invalid manifests better
authorCiaran Gultnieks <ciaran@ciarang.com>
Tue, 26 Jan 2016 22:00:00 +0000 (22:00 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Tue, 26 Jan 2016 22:05:31 +0000 (22:05 +0000)
In other words, don't blow up and kill a whole checkupdates run just
because one version of one package has some invalid xml.

fdroidserver/common.py

index 60d1a7c76f3ddacdb09beb2b603f889955c1fbdc..a20aa59b478822ced8a95353ea62bc29fe4e9d55 100644 (file)
@@ -1072,19 +1072,22 @@ def parse_androidmanifests(paths, app):
                     if matches:
                         vercode = matches.group(1)
         else:
-            xml = parse_xml(path)
-            if "package" in xml.attrib:
-                s = xml.attrib["package"].encode('utf-8')
-                if app_matches_packagename(app, s):
-                    package = s
-            if "{http://schemas.android.com/apk/res/android}versionName" in xml.attrib:
-                version = xml.attrib["{http://schemas.android.com/apk/res/android}versionName"].encode('utf-8')
-                base_dir = os.path.dirname(path)
-                version = retrieve_string_singleline(base_dir, version)
-            if "{http://schemas.android.com/apk/res/android}versionCode" in xml.attrib:
-                a = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"].encode('utf-8')
-                if string_is_integer(a):
-                    vercode = a
+            try:
+                xml = parse_xml(path)
+                if "package" in xml.attrib:
+                    s = xml.attrib["package"].encode('utf-8')
+                    if app_matches_packagename(app, s):
+                        package = s
+                if "{http://schemas.android.com/apk/res/android}versionName" in xml.attrib:
+                    version = xml.attrib["{http://schemas.android.com/apk/res/android}versionName"].encode('utf-8')
+                    base_dir = os.path.dirname(path)
+                    version = retrieve_string_singleline(base_dir, version)
+                if "{http://schemas.android.com/apk/res/android}versionCode" in xml.attrib:
+                    a = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"].encode('utf-8')
+                    if string_is_integer(a):
+                        vercode = a
+            except Exception:
+                logging.warning("Problem with xml at {0}".format(path))
 
         # Remember package name, may be defined separately from version+vercode
         if package is None: