cope with bad icons in the json (bug 741980)

This commit is contained in:
Andy McKay 2012-04-19 17:43:18 -07:00
Родитель 0a9ffff5f8
Коммит 5ea35b87d0
4 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,6 @@
{
"version": "1.0",
"name": "MozillaBall",
"description": "Exciting Open Web development action!",
"icons": {'asd'},
}

Просмотреть файл

@ -331,7 +331,12 @@ def fetch_icon(webapp, **kw):
# Set the icon type to empty.
webapp.update(icon_type='')
return
biggest = max([int(size) for size in manifest['icons']])
try:
biggest = max([int(size) for size in manifest['icons']])
except ValueError:
return
icon_url = manifest['icons'][str(biggest)]
if icon_url.startswith('data:image'):
image_string = icon_url.split('base64,')[1]

Просмотреть файл

@ -0,0 +1,6 @@
{
"version": "1.0",
"name": "MozillaBall",
"description": "Exciting Open Web development action!",
"icons": {'asd'},
}

Просмотреть файл

@ -290,6 +290,12 @@ class TestFetchIcon(BaseWebAppTest):
tasks.fetch_icon(iconless_app)
assert not self.urlopen_mock.called
def test_bad_icons(self):
path = os.path.join(self.apps_path, 'badicon.webapp')
iconless_app = self.webapp_from_path(path)
tasks.fetch_icon(iconless_app)
assert not self.urlopen_mock.called
def check_icons(self, webapp):
manifest = webapp.get_manifest_json()
biggest = max([int(size) for size in manifest['icons']])