Commit 89c7ac6a authored by David Sveningsson's avatar David Sveningsson

feat(elements): src, href, etc attributes cannot be empty

[skip release]
parent 4cd82464
Pipeline #76900612 passed with stages
in 11 minutes and 52 seconds
......@@ -1558,22 +1558,69 @@ exports[`HTML elements <em> valid markup 1`] = `Array []`;
exports[`HTML elements <embed> invalid markup 1`] = `
Array [
Object {
"errorCount": 1,
"errorCount": 4,
"filePath": "test-files/elements/embed-invalid.html",
"messages": Array [
Object {
"column": 15,
"column": 51,
"context": undefined,
"line": 2,
"message": "End tag for <embed> must be omitted",
"offset": 61,
"offset": 97,
"ruleId": "void",
"severity": 2,
"size": 1,
},
Object {
"column": 2,
"context": Object {
"attribute": "src",
"element": "embed",
},
"line": 5,
"message": "<embed> is missing required \\"src\\" attribute",
"offset": 136,
"ruleId": "element-required-attributes",
"severity": 2,
"size": 5,
},
Object {
"column": 2,
"context": Object {
"attribute": "title",
"element": "embed",
},
"line": 5,
"message": "<embed> is missing required \\"title\\" attribute",
"offset": 136,
"ruleId": "element-required-attributes",
"severity": 2,
"size": 5,
},
Object {
"column": 2,
"context": Object {
"allowed": Array [
/\\.\\+/,
],
"attribute": "src",
"element": "embed",
"value": "",
},
"line": 6,
"message": "Attribute \\"src\\" has invalid value \\"\\"",
"offset": 144,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 5,
},
],
"source": "<!-- should not be allowed to have end tag -->
<embed></embed>
<embed src=\\"url\\" title=\\"My embedded thing\\"></embed>
<!-- should have src and title -->
<embed>
<embed src=\\"\\" title=\\"\\">
",
"warningCount": 0,
},
......@@ -2487,7 +2534,7 @@ exports[`HTML elements <i> valid markup 1`] = `Array []`;
exports[`HTML elements <iframe> invalid markup 1`] = `
Array [
Object {
"errorCount": 1,
"errorCount": 2,
"filePath": "test-files/elements/iframe-invalid.html",
"messages": Array [
Object {
......@@ -2503,9 +2550,29 @@ Array [
"severity": 2,
"size": 6,
},
Object {
"column": 2,
"context": Object {
"allowed": Array [
/\\.\\+/,
],
"attribute": "src",
"element": "iframe",
"value": "",
},
"line": 5,
"message": "Attribute \\"src\\" has invalid value \\"\\"",
"offset": 91,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 6,
},
],
"source": "<!-- should require title attribute -->
<iframe></iframe>
<!-- invalid src attribute -->
<iframe src=\\"\\" title=\\"My page\\"></iframe>
",
"warningCount": 0,
},
......@@ -3091,19 +3158,49 @@ exports[`HTML elements <li> valid markup 1`] = `Array []`;
exports[`HTML elements <link> invalid markup 1`] = `
Array [
Object {
"errorCount": 3,
"errorCount": 5,
"filePath": "test-files/elements/link-invalid.html",
"messages": Array [
Object {
"column": 13,
"column": 28,
"context": undefined,
"line": 2,
"message": "End tag for <link> must be omitted",
"offset": 46,
"offset": 61,
"ruleId": "void",
"severity": 2,
"size": 1,
},
Object {
"column": 2,
"context": Object {
"attribute": "href",
"element": "link",
},
"line": 5,
"message": "<link> is missing required \\"href\\" attribute",
"offset": 110,
"ruleId": "element-required-attributes",
"severity": 2,
"size": 4,
},
Object {
"column": 2,
"context": Object {
"allowed": Array [
/\\.\\+/,
],
"attribute": "href",
"element": "link",
"value": "",
},
"line": 6,
"message": "Attribute \\"href\\" has invalid value \\"\\"",
"offset": 117,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 4,
},
Object {
"column": 2,
"context": Object {
......@@ -3114,9 +3211,9 @@ Array [
"element": "link",
"value": "",
},
"line": 5,
"line": 9,
"message": "Attribute \\"integrity\\" has invalid value \\"\\"",
"offset": 99,
"offset": 182,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 4,
......@@ -3131,20 +3228,24 @@ Array [
"element": "link",
"value": "",
},
"line": 6,
"line": 10,
"message": "Attribute \\"integrity\\" has invalid value \\"\\"",
"offset": 116,
"offset": 213,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 4,
},
],
"source": "<!-- should not allow end tag -->
<link></link>
<link href=\\"my-url\\" ></link>
<!-- href should not be omitted or empty -->
<link>
<link href=\\"\\">
<!-- integrity attribute should not be empty -->
<link integrity>
<link integrity=\\"\\">
<link href=\\"my-url\\" integrity>
<link href=\\"my-url\\" integrity=\\"\\">
",
"warningCount": 0,
},
......@@ -3689,7 +3790,7 @@ exports[`HTML elements <noscript> valid markup 1`] = `Array []`;
exports[`HTML elements <object> invalid markup 1`] = `
Array [
Object {
"errorCount": 3,
"errorCount": 4,
"filePath": "test-files/elements/object-invalid.html",
"messages": Array [
Object {
......@@ -3702,12 +3803,29 @@ Array [
"severity": 2,
"size": 3,
},
Object {
"column": 2,
"context": Object {
"allowed": Array [
/\\.\\+/,
],
"attribute": "data",
"element": "object",
"value": "",
},
"line": 9,
"message": "Attribute \\"data\\" has invalid value \\"\\"",
"offset": 118,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 6,
},
Object {
"column": 3,
"context": undefined,
"line": 11,
"line": 14,
"message": "Element <param> must be used before <div> in this context",
"offset": 155,
"offset": 214,
"ruleId": "element-permitted-order",
"severity": 2,
"size": 5,
......@@ -3715,9 +3833,9 @@ Array [
Object {
"column": 3,
"context": undefined,
"line": 16,
"line": 19,
"message": "Element <object> is not permitted as descendant of <button>",
"offset": 246,
"offset": 305,
"ruleId": "element-permitted-content",
"severity": 2,
"size": 6,
......@@ -3730,6 +3848,9 @@ Array [
</object>
</span>
<!-- invalid data attribute -->
<object data=\\"\\"></object>
<!-- should not allow flow before <param> -->
<object>
<div></div>
......@@ -4405,32 +4526,55 @@ exports[`HTML elements <samp> valid markup 1`] = `Array []`;
exports[`HTML elements <script> invalid markup 1`] = `
Array [
Object {
"errorCount": 2,
"errorCount": 3,
"filePath": "test-files/elements/script-invalid.html",
"messages": Array [
Object {
"column": 8,
"context": undefined,
"column": 2,
"context": Object {
"allowed": Array [
/\\.\\+/,
],
"attribute": "src",
"element": "script",
"value": "",
},
"line": 2,
"message": "End tag for <script> must not be omitted",
"offset": 196,
"ruleId": "void",
"message": "Attribute \\"src\\" has invalid value \\"\\"",
"offset": 40,
"ruleId": "attribute-allowed-values",
"severity": 2,
"size": 2,
"size": 6,
},
Object {
"column": 9,
"line": 3,
"message": "failed to tokenize \\"\\\\n\\", expected </script>.",
"offset": 207,
"ruleId": "parser-error",
"context": undefined,
"line": 5,
"message": "Attribute \\"language\\" is deprecated on <script> element",
"offset": 103,
"ruleId": "no-deprecated-attr",
"severity": 2,
"size": 8,
},
Object {
"column": 8,
"context": undefined,
"line": 8,
"message": "End tag for <script> must not be omitted",
"offset": 330,
"ruleId": "void",
"severity": 2,
"size": 0,
"size": 2,
},
],
"source": "<!-- must not omit end tag in any way, because the way the scripttag is tokenized both according to spec and this tool it must explicitly be ended with </>. Dragons ahead if not obeyed -->
"source": "<!-- src attribute cannot be empty -->
<script src=\\"\\"></script>
<!-- deprecated attribute -->
<script language=\\"vbscript\\"></script>
<!-- must not omit end tag in any way, because the way the scripttag is tokenized both according to spec and this tool it must explicitly be ended with </>. Dragons ahead if not obeyed -->
<script/>
<script>
",
"warningCount": 0,
},
......
......@@ -285,7 +285,11 @@
"phrasing": true,
"embedded": true,
"interactive": true,
"void": true
"void": true,
"attributes": {
"src": ["/.+/"]
},
"requiredAttributes": ["src", "title"]
},
"fieldset": {
......@@ -421,6 +425,9 @@
"phrasing": true,
"embedded": true,
"interactive": true,
"attributes": {
"src": ["/.+/"]
},
"deprecatedAttributes": [
"align",
"allowtransparency",
......@@ -572,8 +579,10 @@
"void": true,
"attributes": {
"crossorigin": ["", "anonymous", "use-credentials"],
"integrity": ["/.+/"]
"integrity": ["/.+/"],
"href": ["/.+/"]
},
"requiredAttributes": ["href"],
"deprecatedAttributes": ["charset", "methods", "urn", "target"]
},
......@@ -669,6 +678,9 @@
"embedded": true,
"interactive": ["hasAttribute", "usemap"],
"transparent": true,
"attributes": {
"data": ["/.+/"]
},
"deprecatedAttributes": [
"align",
"archive",
......@@ -840,7 +852,8 @@
"crossorigin": ["", "anonymous", "use-credentials"],
"defer": [],
"integrity": ["/.+/"],
"nomodule": []
"nomodule": [],
"src": ["/.+/"]
},
"deprecatedAttributes": ["language", "event", "for"]
},
......
<!-- should not be allowed to have end tag -->
<embed></embed>
<embed src="url" title="My embedded thing"></embed>
<!-- should have src and title -->
<embed>
<embed src="" title="">
<!-- should omit end tag -->
<embed>
<embed src="url" title="My embedded thing">
<!-- should be allowed as child of phrasing -->
<div><embed></div>
<span><embed></span>
<div><embed src="url" title="My embedded thing"></div>
<span><embed src="url" title="My embedded thing"></span>
......@@ -8,7 +8,7 @@
<head>
<meta>
<script></script>
<link>
<link href="my-url">
<title>lorem ipsum</title>
<base>
</head>
......
<!-- should require title attribute -->
<iframe></iframe>
<!-- invalid src attribute -->
<iframe src="" title="My page"></iframe>
<!-- fallback content -->
<iframe title="lorem ipsum">
<iframe src="page.html" title="lorem ipsum">
foo
</iframe>
<!-- should not allow end tag -->
<link></link>
<link href="my-url" ></link>
<!-- href should not be omitted or empty -->
<link>
<link href="">
<!-- integrity attribute should not be empty -->
<link integrity>
<link integrity="">
<link href="my-url" integrity>
<link href="my-url" integrity="">
<!-- should omit end tag -->
<link>
<link href="my-url">
<!-- integrity attribute -->
<link integrity="sha384-...">
<link href="my-url" integrity="sha384-...">
......@@ -5,6 +5,9 @@
</object>
</span>
<!-- invalid data attribute -->
<object data=""></object>
<!-- should not allow flow before <param> -->
<object>
<div></div>
......
<!-- src attribute cannot be empty -->
<script src=""></script>
<!-- deprecated attribute -->
<script language="vbscript"></script>
<!-- must not omit end tag in any way, because the way the scripttag is tokenized both according to spec and this tool it must explicitly be ended with </>. Dragons ahead if not obeyed -->
<script/>
<script>
<!-- script is allowed almost everywhere -->
<script></script>
<!-- script is allowed almost everywhere -->
<script src="script.js"></script>
<!-- integrity attribute -->
<script integrity="sha384-..."></script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment