diff --git a/apps/files/fixtures/files/theme-invalid-app.jar b/apps/files/fixtures/files/theme-invalid-app.jar new file mode 100644 index 0000000000..3f55306504 Binary files /dev/null and b/apps/files/fixtures/files/theme-invalid-app.jar differ diff --git a/apps/files/tests.py b/apps/files/tests.py index 40d3315d45..dcd545c584 100644 --- a/apps/files/tests.py +++ b/apps/files/tests.py @@ -125,8 +125,8 @@ class TestParseXpi(test_utils.TestCase): for version in ('3.0', '3.6.*'): AppVersion.objects.create(application_id=1, version=version) - def parse(self, addon=None): - path = 'apps/files/fixtures/files/extension.xpi' + def parse(self, addon=None, filename='extension.xpi'): + path = 'apps/files/fixtures/files/' + filename xpi = os.path.join(settings.ROOT, path) return parse_xpi(xpi, addon) @@ -180,6 +180,10 @@ class TestParseXpi(test_utils.TestCase): eq_(e.exception.messages, [" doesn't match add-on"]) + def test_unknown_app(self): + data = self.parse(filename='theme-invalid-app.jar') + eq_(data['apps'], []) + # parse_dictionary # parse_theme # parse_langpack diff --git a/apps/files/utils.py b/apps/files/utils.py index dda3645d4f..36339aee6c 100644 --- a/apps/files/utils.py +++ b/apps/files/utils.py @@ -84,6 +84,8 @@ def parse_xpi(xpi, addon=None): App = collections.namedtuple('App', 'appdata id min max') for node in rdf.getElementsByTagName('em:targetApplication'): app = amo.APP_GUIDS.get(get_text_value(node, 'id')) + if not app: + continue min_val = get_text_value(node, 'minVersion') max_val = get_text_value(node, 'maxVersion')