You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Show different error messages depending on whether referrer is allowed; clarify about `noreferrer` only being necessary in older browsers.
Closes#3044.
Copy file name to clipboardExpand all lines: docs/rules/jsx-no-target-blank.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ This rule aims to prevent user generated link hrefs and form actions from creati
20
20
...
21
21
```
22
22
23
-
*`allowReferrer`: optional boolean. If `true` does not require `noreferrer`. Defaults to `false`.
24
-
*`enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
23
+
*`allowReferrer`: optional boolean. If `true` does not require `noreferrer` (i. e. `noopener` alone is enough, this leaves IE vulnerable). Defaults to `false`.
24
+
*`enabled`: for enabling the rule.
25
25
*`enforceDynamicLinks`: optional string, 'always' or 'never'
26
26
*`warnOnSpreadAttributes`: optional boolean. Defaults to `false`.
27
27
*`enforceDynamicLinks` - enforce: optional string, 'always' or 'never'
@@ -125,6 +125,8 @@ This rule supports the ability to use custom components for forms. To enable thi
125
125
126
126
For links to a trusted host (e.g. internal links to your own site, or links to a another host you control, where you can be certain this security vulnerability does not exist), you may want to keep the HTTP Referer header for analytics purposes.
127
127
128
+
If you do not support Internet Explorer (any version), Chrome < 49, Opera < 36, Firefox < 52, desktop Safari < 10.1 or iOS Safari < 10.3, you may set `allowReferrer` to `true`, keep the HTTP Referer header and only add `rel="noopener"` to your links.
129
+
128
130
## When Not To Use It
129
131
130
132
If you do not have any external links or forms, you can disable this rule.
Copy file name to clipboardExpand all lines: lib/rules/jsx-no-target-blank.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,8 @@ function hasSecureRel(node, allowReferrer, warnOnSpreadAttributes, spreadAttribu
97
97
}
98
98
99
99
constmessages={
100
-
noTargetBlank: 'Using target="_blank" without rel="noreferrer" is a security risk: see https://html.spec.whatwg.org/multipage/links.html#link-type-noopener'
100
+
noTargetBlankWithoutNoreferrer: 'Using target="_blank" without rel="noreferrer" (which implies rel="noopener") is a security risk in older browsers: see https://mathiasbynens.github.io/rel-noopener/#recommendations',
101
+
noTargetBlankWithoutNoopener: 'Using target="_blank" without rel="noreferrer" or rel="noopener" (the former implies the latter and is preferred due to wider support) is a security risk: see https://mathiasbynens.github.io/rel-noopener/#recommendations'
0 commit comments