mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-17 10:40:12 +02:00
Improve xml string extracting support
* Shield ourselves from newlines that would break metadata files * Properly use string resources for version names
This commit is contained in:
parent
52c2ca1fe7
commit
5aa9e2289d
@ -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
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user