mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 06:22:27 +03:00
Merge branch 'noversioncode' into 'master'
update: Handle APKs without a version code in their manifest Closes #1240 See merge request fdroid/fdroidserver!1695
This commit is contained in:
commit
57244dec63
2 changed files with 15 additions and 2 deletions
|
@ -35,6 +35,10 @@ class VCSException(FDroidException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoVersionCodeException(FDroidException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NoSubmodulesException(VCSException):
|
class NoSubmodulesException(VCSException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ import fdroidserver.index
|
||||||
|
|
||||||
from . import _, common, metadata
|
from . import _, common, metadata
|
||||||
from .common import DEFAULT_LOCALE
|
from .common import DEFAULT_LOCALE
|
||||||
from .exception import BuildException, FDroidException, VerificationException
|
from .exception import BuildException, FDroidException, NoVersionCodeException, VerificationException
|
||||||
|
|
||||||
if hasattr(Image, 'DecompressionBombWarning'):
|
if hasattr(Image, 'DecompressionBombWarning'):
|
||||||
warnings.simplefilter('error', Image.DecompressionBombWarning)
|
warnings.simplefilter('error', Image.DecompressionBombWarning)
|
||||||
|
@ -1801,6 +1801,7 @@ def scan_apk_androguard(apk, apkfile):
|
||||||
|
|
||||||
xml = apkobject.get_android_manifest_xml()
|
xml = apkobject.get_android_manifest_xml()
|
||||||
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 = common.XMLNS_ANDROID
|
xmlns = common.XMLNS_ANDROID
|
||||||
|
@ -1810,8 +1811,12 @@ def scan_apk_androguard(apk, apkfile):
|
||||||
xmlns = '{}'
|
xmlns = '{}'
|
||||||
|
|
||||||
vcstr = androidmanifest_xml.get(xmlns + 'versionCode')
|
vcstr = androidmanifest_xml.get(xmlns + 'versionCode')
|
||||||
|
logging.debug("Version Code: %r (%s)" % (vcstr, apkfile))
|
||||||
|
|
||||||
if vcstr.startswith('0x'):
|
if not vcstr:
|
||||||
|
raise NoVersionCodeException(_("APK file {path} does not have a version code "
|
||||||
|
"in its manifest").format(path=apkfile))
|
||||||
|
elif vcstr.startswith('0x'):
|
||||||
apk['versionCode'] = int(vcstr, 16)
|
apk['versionCode'] = int(vcstr, 16)
|
||||||
else:
|
else:
|
||||||
apk['versionCode'] = int(vcstr)
|
apk['versionCode'] = int(vcstr)
|
||||||
|
@ -1959,6 +1964,10 @@ def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=Fal
|
||||||
logging.warning(_("Skipping '{apkfilename}' with invalid signature!")
|
logging.warning(_("Skipping '{apkfilename}' with invalid signature!")
|
||||||
.format(apkfilename=apkfilename))
|
.format(apkfilename=apkfilename))
|
||||||
return True, None, False
|
return True, None, False
|
||||||
|
except NoVersionCodeException:
|
||||||
|
logging.warning(_("Skipping '{apkfilename}' without versionCode!")
|
||||||
|
.format(apkfilename=apkfilename))
|
||||||
|
return True, None, False
|
||||||
|
|
||||||
if apps:
|
if apps:
|
||||||
if apk['packageName'] in apps:
|
if apk['packageName'] in apps:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue