mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 23:42:37 +03:00
use global constant for the 'xmlns:android' XML namespace
This commit is contained in:
parent
3e1d313b7c
commit
cc94ebca30
2 changed files with 8 additions and 7 deletions
|
@ -73,6 +73,7 @@ STANDARD_FILE_NAME_REGEX = re.compile(r'^(\w[\w.]*)_(-?[0-9]+)\.\w+')
|
||||||
|
|
||||||
MAX_VERSION_CODE = 0x7fffffff # Java's Integer.MAX_VALUE (2147483647)
|
MAX_VERSION_CODE = 0x7fffffff # Java's Integer.MAX_VALUE (2147483647)
|
||||||
|
|
||||||
|
XMLNS_ANDROID = '{http://schemas.android.com/apk/res/android}'
|
||||||
XMLElementTree.register_namespace('android', 'http://schemas.android.com/apk/res/android')
|
XMLElementTree.register_namespace('android', 'http://schemas.android.com/apk/res/android')
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
|
@ -1289,9 +1290,9 @@ def fetch_real_name(app_dir, flavours):
|
||||||
app = xml.find('application')
|
app = xml.find('application')
|
||||||
if app is None:
|
if app is None:
|
||||||
continue
|
continue
|
||||||
if "{http://schemas.android.com/apk/res/android}label" not in app.attrib:
|
if XMLNS_ANDROID + "label" not in app.attrib:
|
||||||
continue
|
continue
|
||||||
label = app.attrib["{http://schemas.android.com/apk/res/android}label"]
|
label = app.attrib[XMLNS_ANDROID + "label"]
|
||||||
result = retrieve_string_singleline(app_dir, label)
|
result = retrieve_string_singleline(app_dir, label)
|
||||||
if result:
|
if result:
|
||||||
result = result.strip()
|
result = result.strip()
|
||||||
|
@ -1471,12 +1472,12 @@ def parse_androidmanifests(paths, app):
|
||||||
s = xml.attrib["package"]
|
s = xml.attrib["package"]
|
||||||
if app_matches_packagename(app, s):
|
if app_matches_packagename(app, s):
|
||||||
package = s
|
package = s
|
||||||
if "{http://schemas.android.com/apk/res/android}versionName" in xml.attrib:
|
if XMLNS_ANDROID + "versionName" in xml.attrib:
|
||||||
version = xml.attrib["{http://schemas.android.com/apk/res/android}versionName"]
|
version = xml.attrib[XMLNS_ANDROID + "versionName"]
|
||||||
base_dir = os.path.dirname(path)
|
base_dir = os.path.dirname(path)
|
||||||
version = retrieve_string_singleline(base_dir, version)
|
version = retrieve_string_singleline(base_dir, version)
|
||||||
if "{http://schemas.android.com/apk/res/android}versionCode" in xml.attrib:
|
if XMLNS_ANDROID + "versionCode" in xml.attrib:
|
||||||
a = xml.attrib["{http://schemas.android.com/apk/res/android}versionCode"]
|
a = xml.attrib[XMLNS_ANDROID + "versionCode"]
|
||||||
if string_is_integer(a):
|
if string_is_integer(a):
|
||||||
vercode = a
|
vercode = a
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -1237,7 +1237,7 @@ def scan_apk_androguard(apk, apkfile):
|
||||||
androidmanifest_xml = apkobject.xml['AndroidManifest.xml']
|
androidmanifest_xml = apkobject.xml['AndroidManifest.xml']
|
||||||
if len(xml.nsmap) > 0:
|
if len(xml.nsmap) > 0:
|
||||||
# one of them surely will be the Android one, or its corrupt
|
# one of them surely will be the Android one, or its corrupt
|
||||||
xmlns = '{http://schemas.android.com/apk/res/android}'
|
xmlns = common.XMLNS_ANDROID
|
||||||
else:
|
else:
|
||||||
# strange but sometimes the namespace is blank. This seems to
|
# strange but sometimes the namespace is blank. This seems to
|
||||||
# only happen with the Bromite/Chromium APKs
|
# only happen with the Bromite/Chromium APKs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue