Error Codes
Estimated reading time: 4 minutesThe XSS detection engine emits four diagnostic codes. Each code links to a specific kind of safety issue with a defined fix.
TS88601 Error
Content may introduce an XSS vulnerability and must be marked with the safe
attribute.
An expression with type string or any is used as a child of a native element without
the safe attribute.
Variables prefixed with safe are exempt from this rule, as are expressions with safe
types (numbers, booleans, string literals...).
Add the safe attribute to escape the content
TS88602 Error
The safe attribute causes this content to be escaped more than once.
Severity: error. The safe attribute is applied to an element whose children include JSX
elements. This would escape the HTML output of those child components, corrupting their
markup.
You can also wrap inner components inside fragments or use escapeHtml() manually to
avoid the double escaping.
Remove safe from the parent element. You can use Fragment to apply safe to a group
of children without affecting nested components, since fragments don't render actual HTML
elements.
TS88603 Error
Content inside a Component must be escaped using escapeHtml().
An expression with type string or any is passed as a child to a component (uppercase
tag name). Unlike native elements, components cannot use the safe attribute directly on
children.
Components cannot apply the safe attribute directly to their children. You must either
escape the content before passing it, or wrap it in a Fragment with the safe attribute.
Escape manually using Html.escapeHtml()
Or wrap the content in a Fragment with safe
TS88604 Warning
The safe attribute is unused in this context.
The safe attribute is applied to an element whose children are already safe types
(numbers, booleans, JSX.Element, etc.). The escaping is redundant and can be removed.
Numbers, booleans, bigints, string literals, and JSX.Element types are already safe and
cannot introduce XSS vulnerabilities. The safe attribute has no effect on these types.
Remove the safe attribute since numbers are already safe