mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
Handle BadZipFile
This commit is contained in:
parent
925cdbe542
commit
c80fdd5ce8
1 changed files with 13 additions and 10 deletions
|
|
@ -115,6 +115,7 @@ def get_embedded_classes(apkfile, depth=0):
|
||||||
class_regex = re.compile(r'classes.*\.dex')
|
class_regex = re.compile(r'classes.*\.dex')
|
||||||
classes = set()
|
classes = set()
|
||||||
|
|
||||||
|
try:
|
||||||
with TemporaryDirectory() as tmp_dir, zipfile.ZipFile(apkfile, 'r') as apk_zip:
|
with TemporaryDirectory() as tmp_dir, zipfile.ZipFile(apkfile, 'r') as apk_zip:
|
||||||
for info in apk_zip.infolist():
|
for info in apk_zip.infolist():
|
||||||
# apk files can contain apk files, again
|
# apk files can contain apk files, again
|
||||||
|
|
@ -126,6 +127,8 @@ def get_embedded_classes(apkfile, depth=0):
|
||||||
apk_zip.extract(info, tmp_dir)
|
apk_zip.extract(info, tmp_dir)
|
||||||
run = common.SdkToolsPopen(["dexdump", '{}/{}'.format(tmp_dir, info.filename)])
|
run = common.SdkToolsPopen(["dexdump", '{}/{}'.format(tmp_dir, info.filename)])
|
||||||
classes = classes.union(set(re.findall(r'[A-Z]+((?:\w+\/)+\w+)', run.output)))
|
classes = classes.union(set(re.findall(r'[A-Z]+((?:\w+\/)+\w+)', run.output)))
|
||||||
|
except zipfile.BadZipFile as ex:
|
||||||
|
return {_('Problem with ZIP file: %s, error %s') % (apkfile, ex)}
|
||||||
|
|
||||||
return classes
|
return classes
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue