diff --git a/tests/resources/installrdf/doctype.rdf b/tests/resources/installrdf/doctype.rdf new file mode 100644 index 0000000..d576c6a --- /dev/null +++ b/tests/resources/installrdf/doctype.rdf @@ -0,0 +1,33 @@ + + + + + + + + 2 + + bastatestapp1@basta.mozilla.com + 1.2.3.4 + name_value + description_value + creator_value + hompage_url_value + + contributor_1_value + contributor_2_value + contributor_3_value + contributor_4_value + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 3.7a5pre + 0.3 + + + + + + diff --git a/tests/test_submain_install_rdf.py b/tests/test_submain_install_rdf.py index 797be98..f433939 100644 --- a/tests/test_submain_install_rdf.py +++ b/tests/test_submain_install_rdf.py @@ -67,4 +67,25 @@ def test_load_irdf_expectation(): submain.typedetection.detect_type = lambda x, y, z: PACKAGE_THEME _run_test("install_rdf.xpi", PACKAGE_EXTENSION, True, True) submain.typedetection.detect_type = dt - + +def test_doctype(): + "Asserts that install.rdf files with doctypes break validation" + + err = ErrorBundle() + xpi = MockXPIManager( + {"install.rdf": "tests/resources/installrdf/doctype.rdf"}) + assert isinstance(submain._load_install_rdf(err, xpi, None), ErrorBundle) + assert err.failed() + assert not err.get_resource("has_install_rdf") + assert not err.get_resource("install_rdf") + +class MockXPIManager(object): + "Pretends to be a simple XPI manager" + + def __init__(self, data): + self.data = data + + def read(self, name): + "Simulates a read operation" + assert name in self.data + return open(self.data[name]).read() diff --git a/validator/submain.py b/validator/submain.py index a11837d..292a4f8 100644 --- a/validator/submain.py +++ b/validator/submain.py @@ -1,4 +1,5 @@ import os +import re import zipfile @@ -142,6 +143,18 @@ def test_package(err, file_, name, expectation=PACKAGE_ANY): def _load_install_rdf(err, package, expectation): # Load up the install.rdf file. install_rdf_data = package.read("install.rdf") + + if re.search('