noDangerouslySetInnerHtml
诊断类别:lint/security/noDangerouslySetInnerHtml
¥Diagnostic Category: lint/security/noDangerouslySetInnerHtml
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
react/no-danger
¥Same as:
react/no-danger
防止使用危险的 JSX props
¥Prevent the usage of dangerous JSX props
¥Examples
¥Invalid
code-block.jsx:4:6 lint/security/noDangerouslySetInnerHtml ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid passing content using the dangerouslySetInnerHTML prop.
2 │ return { __html: ‘child’ }
3 │ }
> 4 │ <div dangerouslySetInnerHTML={createMarkup()}></div>
│ ^^^^^^^^^^^^^^^^^^^^^^^
5 │
⚠ Setting content using code can expose users to cross-site scripting (XSS) attacks
code-block.js:2:5 lint/security/noDangerouslySetInnerHtml ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid passing content using the dangerouslySetInnerHTML prop.
1 │ React.createElement(‘div’, {
> 2 │ dangerouslySetInnerHTML: { __html: ‘child’ }
│ ^^^^^^^^^^^^^^^^^^^^^^^
3 │ });
4 │
⚠ Setting content using code can expose users to cross-site scripting (XSS) attacks
¥Related links