chiark / gitweb /
Improve xml string extracting support
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 18 Jun 2015 15:54:56 +0000 (17:54 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 18 Jun 2015 15:54:56 +0000 (17:54 +0200)
* Shield ourselves from newlines that would break metadata files
* Properly use string resources for version names

fdroidserver/checkupdates.py
fdroidserver/common.py

index 8a480d16e31a6b779d628252a68e23db93151148..5d81ee376dc45fc95f8bf198de6e235f694a931c 100644 (file)
@@ -366,13 +366,6 @@ def fetch_autoname(app, tag):
     else:
         logging.debug("...couldn't get autoname")
 
-    if app['Current Version'].startswith('@string/'):
-        cv = common.version_name(app['Current Version'], app_dir, flavours)
-        if app['Current Version'] != cv:
-            app['Current Version'] = cv
-            if not commitmsg:
-                commitmsg = "Fix CV of {0}".format(common.getappname(app))
-
     return commitmsg
 
 
index 9e51ffdf09658e8c8a8bdacc4fbd1c9250c86b0c..14498ecfd737a726ba8ed841396f2cc0efc5bda9 100644 (file)
@@ -894,6 +894,10 @@ def retrieve_string(app_dir, string, xmlfiles=None):
     return ''
 
 
+def retrieve_string_singleline(app_dir, string, xmlfiles=None):
+    return retrieve_string(app_dir, string, xmlfiles).replace('\n', ' ').strip()
+
+
 # Return list of existing files that will be used to find the highest vercode
 def manifest_paths(app_dir, flavours):
 
@@ -923,24 +927,13 @@ def fetch_real_name(app_dir, flavours):
         if "{http://schemas.android.com/apk/res/android}label" not in app.attrib:
             continue
         label = app.attrib["{http://schemas.android.com/apk/res/android}label"].encode('utf-8')
-        result = retrieve_string(app_dir, label)
+        result = retrieve_string_singleline(app_dir, label)
         if result:
             result = result.strip()
         return result
     return None
 
 
-# Retrieve the version name
-def version_name(original, app_dir, flavours):
-    for path in manifest_paths(app_dir, flavours):
-        if not has_extension(path, 'xml'):
-            continue
-        string = retrieve_string(app_dir, original)
-        if string:
-            return string
-    return original
-
-
 def get_library_references(root_dir):
     libraries = []
     proppath = os.path.join(root_dir, 'project.properties')
@@ -1030,6 +1023,8 @@ def parse_androidmanifests(paths, ignoreversions=None):
                 package = xml.attrib["package"].encode('utf-8')
             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):