From cd93d2306217528d4bcfe3dcb2ccbe49abdf7c56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Wed, 3 Jun 2015 18:42:24 +0200 Subject: [PATCH] Work around encoding issues when using xml files The xml package returns "unicode" objects instead of strings in utf-8. --- fdroidserver/common.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 7a2c6938..bad39a00 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -882,7 +882,7 @@ def retrieve_string(app_dir, string, xmlfiles=None): xml = parse_xml(path) element = xml.find('string[@name="' + name + '"]') if element is not None: - return retrieve_string(app_dir, element.text, xmlfiles) + return retrieve_string(app_dir, element.text.encode('utf-8'), xmlfiles) return '' @@ -915,7 +915,7 @@ def fetch_real_name(app_dir, flavours): app = xml.find('application') 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"] + label = app.attrib["{http://schemas.android.com/apk/res/android}label"].encode('utf-8') result = retrieve_string(app_dir, label) if result: result = result.strip() @@ -1020,11 +1020,11 @@ def parse_androidmanifests(paths, ignoreversions=None): else: xml = parse_xml(path) if "package" in xml.attrib: - package = xml.attrib["package"] + 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"] + version = xml.attrib["{http://schemas.android.com/apk/res/android}versionName"].encode('utf-8') if "{http://schemas.android.com/apk/res/android}versionCode" in xml.attrib: - vercode = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"] + vercode = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"].encode('utf-8') logging.debug("..got package={0}, version={1}, vercode={2}" .format(package, version, vercode)) -- 2.30.2