From 5aa9e2289d320443b30806d057e267fb18766730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 18 Jun 2015 17:54:56 +0200 Subject: [PATCH] Improve xml string extracting support * Shield ourselves from newlines that would break metadata files * Properly use string resources for version names --- fdroidserver/checkupdates.py | 7 ------- fdroidserver/common.py | 19 +++++++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 8a480d16..5d81ee37 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -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 diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 9e51ffdf..14498ecf 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -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):