From 09bbca4a51ad0f77d5b37d06ed0878dc2c6c37ce Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 1 Feb 2019 09:49:07 +0100 Subject: [PATCH] update: force all "SDK Version" values to int when parsing aapt --- fdroidserver/update.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index dbc44f23..58890074 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1148,16 +1148,16 @@ def scan_apk_aapt(apk, apkfile): logging.error(line.replace('sdkVersion:', '') + ' is not a valid minSdkVersion!') else: - apk['minSdkVersion'] = m.group(1) + apk['minSdkVersion'] = int(m.group(1)) elif line.startswith("targetSdkVersion:"): m = re.match(APK_SDK_VERSION_PAT, line) if m is None: logging.error(line.replace('targetSdkVersion:', '') + ' is not a valid targetSdkVersion!') else: - apk['targetSdkVersion'] = m.group(1) + apk['targetSdkVersion'] = int(m.group(1)) elif line.startswith("maxSdkVersion:"): - apk['maxSdkVersion'] = re.match(APK_SDK_VERSION_PAT, line).group(1) + apk['maxSdkVersion'] = int(re.match(APK_SDK_VERSION_PAT, line).group(1)) elif line.startswith("native-code:"): apk['nativecode'] = [] for arch in line[13:].split(' '): @@ -1193,12 +1193,14 @@ def scan_apk_aapt(apk, apkfile): def _sanitize_sdk_version(value): """Sanitize the raw values from androguard to handle bad values - minSdkVersion/targetSdkVersion/maxSdkVersion must be integers, - but that doesn't stop devs from doing strange things like - setting them using Android XML strings. + minSdkVersion/targetSdkVersion/maxSdkVersion must be integers, but + that doesn't stop devs from doing strange things like setting them + using Android XML strings. This method makes the Androguard output + match the output from `aapt dump badging`: bad values are ignored. https://gitlab.com/souch/SMSbypass/blob/v0.9/app/src/main/AndroidManifest.xml#L29 https://gitlab.com/souch/SMSbypass/blob/v0.9/app/src/main/res/values/strings.xml#L27 + """ try: sdk_version = int(value)