diff --git a/lint.ignore b/lint.ignore index b33209114c3e7b..e0ba1ad4c0458e 100644 --- a/lint.ignore +++ b/lint.ignore @@ -707,3 +707,17 @@ SET TIMEOUT: editing/crashtests/outdent-across-svg-boundary.html SET TIMEOUT: editing/crashtests/textarea-will-be-blurred-by-focus-event-listener.html SET TIMEOUT: mathml/crashtests/mozilla/* PARSE-FAILED: mathml/crashtests/mozilla/289180-1.xml + +# Invalid HTML syntax /> on non-void elements +HTML INVALID SYNTAX: acid/* +HTML INVALID SYNTAX: conformance-checkers/* +HTML INVALID SYNTAX: css/css-scoping/shadow-cascade-order-001.html +HTML INVALID SYNTAX: dom/nodes/Document-createElement-namespace.html +HTML INVALID SYNTAX: dom/nodes/Node-lookupNamespaceURI.html +HTML INVALID SYNTAX: dom/nodes/Node-normalize.html +HTML INVALID SYNTAX: domparsing/DOMParser-parseFromString-xml-doctype.html +HTML INVALID SYNTAX: domparsing/DOMParser-parseFromString-xml-parsererror.html +HTML INVALID SYNTAX: domparsing/XMLSerializer-serializeToString.html +HTML INVALID SYNTAX: html/canvas/element/manual/unclosed-canvas-4.htm +HTML INVALID SYNTAX: quirks/percentage-height-calculation.html +HTML INVALID SYNTAX: trusted-types/TrustedTypePolicyFactory-getAttributeType-namespace.tentative.html diff --git a/tools/lint/lint.py b/tools/lint/lint.py index cc4272a7678d39..67cbddce73fb6c 100644 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -352,7 +352,8 @@ def filter_ignorelist_errors(data: Ignorelist, errors: Sequence[rules.Error]) -> rules.SpecialPowersRegexp, rules.AssertThrowsRegexp, rules.PromiseRejectsRegexp, - rules.AssertPreconditionRegexp]] + rules.AssertPreconditionRegexp, + rules.HTMLInvalidSyntaxRegexp]] def check_regexp_line(repo_root: Text, path: Text, f: IO[bytes]) -> List[rules.Error]: diff --git a/tools/lint/rules.py b/tools/lint/rules.py index 580ef8009cdb82..06c4f579e6767d 100644 --- a/tools/lint/rules.py +++ b/tools/lint/rules.py @@ -502,3 +502,15 @@ class AssertPreconditionRegexp(Regexp): file_extensions = [".html", ".htm", ".js", ".xht", ".xhtml", ".svg"] description = "Test-file line has an `assert_precondition(...)` call" to_fix = """Replace with `assert_implements` or `assert_implements_optional`""" + + +class HTMLInvalidSyntaxRegexp(Regexp): + pattern = (br"<(a|abbr|article|audio|b|bdi|bdo|blockquote|body|button|canvas|caption|cite|code|colgroup|data|datalist|dd|del|details|" + br"dfn|dialog|div|dl|dt|em|fieldset|figcaption|figure|footer|form|h[1-6]|head|header|html|i|iframe|ins|kbd|label|legend|li|" + br"main|map|mark|menu|meter|nav|noscript|object|ol|optgroup|option|output|p|picture|pre|progress|q|rp|rt|ruby|s|samp|script|" + br"search|section|select|slot|small|span|strong|style|sub|summary|sup|table|tbody|td|template|textarea|tfoot|th|thead|time|" + br"title|tr|u|ul|var|video)(\s+[^>]+)?\s*/>") + name = "HTML INVALID SYNTAX" + file_extensions = [".html", ".htm"] + description = "Test-file line has a non-void HTML tag with /> syntax" + to_fix = """Replace with start tag and end tag""" diff --git a/tools/lint/tests/test_file_lints.py b/tools/lint/tests/test_file_lints.py index 62a380e1a40743..96eaf9b84cd457 100644 --- a/tools/lint/tests/test_file_lints.py +++ b/tools/lint/tests/test_file_lints.py @@ -233,6 +233,16 @@ def test_no_missing_deps(): assert errors == [] +def test_html_invalid_syntax(): + error_map = check_with_files(b"
") + + for (filename, (errors, kind)) in error_map.items(): + check_errors(errors) + + if kind == "web-lax": + assert errors == [("HTML INVALID SYNTAX", "Test-file line has a non-void HTML tag with /> syntax", filename, 1)] + + def test_meta_timeout(): code = b"""