unsafe_html
Avoid unsafe HTML APIs.
Details
#NOTE: This lint is deprecated and will be removed in a future release. Remove all inclusions of this lint from your analysis options.
AVOID
- assigning directly to the
hreffield of an AnchorElement -
assigning directly to the
srcfield of an EmbedElement, IFrameElement, or ScriptElement - assigning directly to the
srcdocfield of an IFrameElement - calling the
createFragmentmethod of Element - calling the
openmethod of Window - calling the
setInnerHtmlmethod of Element - calling the
Element.htmlconstructor - calling the
DocumentFragment.htmlconstructor
BAD:
dart
var script = ScriptElement()..src = 'foo.js';
This rule has been removed.
Enable
#
To enable the unsafe_html rule, add unsafe_html under
linter > rules in your analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- unsafe_html
If you're instead using the YAML map syntax to configure linter rules,
add unsafe_html: true under linter > rules:
analysis_options.yaml
yaml
linter:
rules:
unsafe_html: true
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.9.2 版本报告页面问题。