Class TrustedHTML
public
Module:
@ember/template
Since:
v6.7.0
A wrapper around a string that has been marked as "trusted". When rendered in HTML, Ember will not perform any escaping.
Note:
This does not make the string safe; it means that some code in your application has marked it as trusted using the
trustHTML()
function.The only public API for getting a
TrutsedHTML
is callingtrustHTML()
. It is not user-constructible.
If a string contains user inputs or other untrusted data, you must sanitize
the string before using the trustHTML
method. Otherwise your code is
vulnerable to Cross-Site Scripting. There are many open source
sanitization libraries to choose from, both for front end and server-side
sanitization.
import { trustHTML } from '@ember/template';
let someTrustedOrSanitizedString = "<div>Hello!</div>"
trustHTML(someTrustedorSanitizedString);