diff --git a/.node-version b/.node-version
new file mode 100644
index 0000000000..28c34d2cd8
--- /dev/null
+++ b/.node-version
@@ -0,0 +1 @@
+14.19.0
diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts
index 391ce6bace..6218032ee0 100644
--- a/src/compiler/compile/nodes/Element.ts
+++ b/src/compiler/compile/nodes/Element.ts
@@ -628,10 +628,11 @@ export default class Element extends Node {
const rel = attribute_map.get('rel');
if (rel == null || rel.is_static) {
const rel_values = rel ? rel.get_static_value().split(regex_any_repeated_whitespaces) : [];
- if (!rel || (!rel_values.includes('noopener') && !rel_values.includes('noreferrer'))) {
+ if (!rel || (!rel_values.includes('noreferrer'))) {
component.warn(this, {
- code: 'security-anchor-rel-noopener',
- message: 'Security: Anchor with "target=_blank" should have rel attribute containing the value "noopener" or "noreferrer"'
+ code: 'security-anchor-rel-noreferrer',
+ message:
+ 'Security: Anchor with "target=_blank" should have rel attribute containing the value "noreferrer"'
});
}
}
diff --git a/test/validator/samples/security-anchor-rel-noopener-legacy/_config.js b/test/validator/samples/security-anchor-rel-noopener-legacy/_config.js
new file mode 100644
index 0000000000..52f59c8767
--- /dev/null
+++ b/test/validator/samples/security-anchor-rel-noopener-legacy/_config.js
@@ -0,0 +1,3 @@
+export default {
+ legacy: true
+};
diff --git a/test/validator/samples/security-anchor-rel-noopener-legacy/input.svelte b/test/validator/samples/security-anchor-rel-noopener-legacy/input.svelte
new file mode 100644
index 0000000000..f5361e5cfe
--- /dev/null
+++ b/test/validator/samples/security-anchor-rel-noopener-legacy/input.svelte
@@ -0,0 +1,33 @@
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+svelte website (invalid)
+Same host (valid)
+Same host (valid)
+Same host (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+svelte website (valid)
+
+svelte website (valid)
diff --git a/test/validator/samples/security-anchor-rel-noopener-legacy/warnings.json b/test/validator/samples/security-anchor-rel-noopener-legacy/warnings.json
new file mode 100644
index 0000000000..24c10fb763
--- /dev/null
+++ b/test/validator/samples/security-anchor-rel-noopener-legacy/warnings.json
@@ -0,0 +1,272 @@
+[
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 73,
+ "column": 73,
+ "line": 1
+ },
+ "pos": 0,
+ "start": {
+ "character": 0,
+ "column": 0,
+ "line": 1
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 154,
+ "column": 80,
+ "line": 2
+ },
+ "pos": 74,
+ "start": {
+ "character": 74,
+ "column": 0,
+ "line": 2
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 243,
+ "column": 88,
+ "line": 3
+ },
+ "pos": 155,
+ "start": {
+ "character": 155,
+ "column": 0,
+ "line": 3
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 319,
+ "column": 75,
+ "line": 4
+ },
+ "pos": 244,
+ "start": {
+ "character": 244,
+ "column": 0,
+ "line": 4
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 402,
+ "column": 82,
+ "line": 5
+ },
+ "pos": 320,
+ "start": {
+ "character": 320,
+ "column": 0,
+ "line": 5
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 493,
+ "column": 90,
+ "line": 6
+ },
+ "pos": 403,
+ "start": {
+ "character": 403,
+ "column": 0,
+ "line": 6
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 561,
+ "column": 67,
+ "line": 7
+ },
+ "pos": 494,
+ "start": {
+ "character": 494,
+ "column": 0,
+ "line": 7
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 636,
+ "column": 74,
+ "line": 8
+ },
+ "pos": 562,
+ "start": {
+ "character": 562,
+ "column": 0,
+ "line": 8
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 719,
+ "column": 82,
+ "line": 9
+ },
+ "pos": 637,
+ "start": {
+ "character": 637,
+ "column": 0,
+ "line": 9
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 792,
+ "column": 72,
+ "line": 10
+ },
+ "pos": 720,
+ "start": {
+ "character": 720,
+ "column": 0,
+ "line": 10
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 872,
+ "column": 79,
+ "line": 11
+ },
+ "pos": 793,
+ "start": {
+ "character": 793,
+ "column": 0,
+ "line": 11
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 960,
+ "column": 87,
+ "line": 12
+ },
+ "pos": 873,
+ "start": {
+ "character": 873,
+ "column": 0,
+ "line": 12
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 1033,
+ "column": 72,
+ "line": 13
+ },
+ "pos": 961,
+ "start": {
+ "character": 961,
+ "column": 0,
+ "line": 13
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 1113,
+ "column": 79,
+ "line": 14
+ },
+ "pos": 1034,
+ "start": {
+ "character": 1034,
+ "column": 0,
+ "line": 14
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 1201,
+ "column": 87,
+ "line": 15
+ },
+ "pos": 1114,
+ "start": {
+ "character": 1114,
+ "column": 0,
+ "line": 15
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 1277,
+ "column": 75,
+ "line": 16
+ },
+ "pos": 1202,
+ "start": {
+ "character": 1202,
+ "column": 0,
+ "line": 16
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 1360,
+ "column": 82,
+ "line": 17
+ },
+ "pos": 1278,
+ "start": {
+ "character": 1278,
+ "column": 0,
+ "line": 17
+ }
+ },
+ {
+ "code": "security-anchor-rel-noreferrer",
+ "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noreferrer\"",
+ "end": {
+ "character": 1451,
+ "column": 90,
+ "line": 18
+ },
+ "pos": 1361,
+ "start": {
+ "character": 1361,
+ "column": 0,
+ "line": 18
+ }
+ }
+]
diff --git a/test/validator/samples/security-anchor-rel-noopener/warnings.json b/test/validator/samples/security-anchor-rel-noopener/warnings.json
index 5a59064a0a..fe51488c70 100644
--- a/test/validator/samples/security-anchor-rel-noopener/warnings.json
+++ b/test/validator/samples/security-anchor-rel-noopener/warnings.json
@@ -1,272 +1 @@
-[
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 73,
- "column": 73,
- "line": 1
- },
- "pos": 0,
- "start": {
- "character": 0,
- "column": 0,
- "line": 1
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 154,
- "column": 80,
- "line": 2
- },
- "pos": 74,
- "start": {
- "character": 74,
- "column": 0,
- "line": 2
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 243,
- "column": 88,
- "line": 3
- },
- "pos": 155,
- "start": {
- "character": 155,
- "column": 0,
- "line": 3
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 319,
- "column": 75,
- "line": 4
- },
- "pos": 244,
- "start": {
- "character": 244,
- "column": 0,
- "line": 4
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 402,
- "column": 82,
- "line": 5
- },
- "pos": 320,
- "start": {
- "character": 320,
- "column": 0,
- "line": 5
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 493,
- "column": 90,
- "line": 6
- },
- "pos": 403,
- "start": {
- "character": 403,
- "column": 0,
- "line": 6
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 561,
- "column": 67,
- "line": 7
- },
- "pos": 494,
- "start": {
- "character": 494,
- "column": 0,
- "line": 7
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 636,
- "column": 74,
- "line": 8
- },
- "pos": 562,
- "start": {
- "character": 562,
- "column": 0,
- "line": 8
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 719,
- "column": 82,
- "line": 9
- },
- "pos": 637,
- "start": {
- "character": 637,
- "column": 0,
- "line": 9
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 792,
- "column": 72,
- "line": 10
- },
- "pos": 720,
- "start": {
- "character": 720,
- "column": 0,
- "line": 10
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 872,
- "column": 79,
- "line": 11
- },
- "pos": 793,
- "start": {
- "character": 793,
- "column": 0,
- "line": 11
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 960,
- "column": 87,
- "line": 12
- },
- "pos": 873,
- "start": {
- "character": 873,
- "column": 0,
- "line": 12
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 1033,
- "column": 72,
- "line": 13
- },
- "pos": 961,
- "start": {
- "character": 961,
- "column": 0,
- "line": 13
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 1113,
- "column": 79,
- "line": 14
- },
- "pos": 1034,
- "start": {
- "character": 1034,
- "column": 0,
- "line": 14
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 1201,
- "column": 87,
- "line": 15
- },
- "pos": 1114,
- "start": {
- "character": 1114,
- "column": 0,
- "line": 15
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 1277,
- "column": 75,
- "line": 16
- },
- "pos": 1202,
- "start": {
- "character": 1202,
- "column": 0,
- "line": 16
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 1360,
- "column": 82,
- "line": 17
- },
- "pos": 1278,
- "start": {
- "character": 1278,
- "column": 0,
- "line": 17
- }
- },
- {
- "code": "security-anchor-rel-noopener",
- "message": "Security: Anchor with \"target=_blank\" should have rel attribute containing the value \"noopener\" or \"noreferrer\"",
- "end": {
- "character": 1451,
- "column": 90,
- "line": 18
- },
- "pos": 1361,
- "start": {
- "character": 1361,
- "column": 0,
- "line": 18
- }
- }
-]
+[]