1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 14:30:11 +01:00

Merge branch 'fix-icon-crash' into 'master'

Fix crash when icon_name is None

See merge request fdroid/fdroidserver!485
This commit is contained in:
Hans-Christoph Steiner 2018-04-04 17:04:24 +00:00
commit c54e32a3b8
2 changed files with 11 additions and 1 deletions

View File

@ -1086,7 +1086,7 @@ def _get_apk_icons_src(apkfile, icon_name):
"""
icons_src = dict()
density_re = re.compile('^res/(.*)/' + icon_name + '\.(png|xml)$')
density_re = re.compile('^res/(.*)/{}\.(png|xml)$'.format(icon_name))
with zipfile.ZipFile(apkfile) as zf:
for filename in zf.namelist():
m = density_re.match(filename)

View File

@ -647,6 +647,16 @@ class UpdateTest(unittest.TestCase):
with self.assertRaises(fdroidserver.exception.FDroidException):
fdroidserver.update.has_known_vulnerability('janus.apk')
def test_get_apk_icon_when_src_is_none(self):
config = dict()
fdroidserver.common.fill_config_defaults(config)
fdroidserver.common.config = config
fdroidserver.update.config = config
# pylint: disable=protected-access
icons_src = fdroidserver.update._get_apk_icons_src('urzip-release.apk', None)
assert icons_src == {}
if __name__ == "__main__":
parser = optparse.OptionParser()