home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
6.7
  • Packages
    • @ember/application
    • @ember/application/namespace
    • @ember/array
    • @ember/array/proxy
    • @ember/canary-features
    • @ember/component
    • @ember/component/template-only
    • @ember/controller
    • @ember/debug
    • @ember/debug/container-debug-adapter
    • @ember/debug/data-adapter
    • @ember/destroyable
    • @ember/engine
    • @ember/helper
    • @ember/object
    • @ember/object/core
    • @ember/object/evented
    • @ember/object/mixin
    • @ember/object/observable
    • @ember/object/promise-proxy-mixin
    • @ember/object/proxy
    • @ember/owner
    • @ember/renderer
    • @ember/routing
    • @ember/routing/hash-location
    • @ember/routing/history-location
    • @ember/routing/location
    • @ember/routing/none-location
    • @ember/routing/route
    • @ember/routing/route-info
    • @ember/routing/router
    • @ember/routing/router-service
    • @ember/routing/transition
    • @ember/runloop
    • @ember/service
    • @ember/template
    • @ember/test
    • @ember/utils
    • @glimmer/component
    • @glimmer/tracking
    • @glimmer/tracking/primitives/cache
    • rsvp
  • Classes
    • Application
    • ApplicationInstance
    • ApplicationInstance.BootOptions
    • ArrayProxy
    • Component
    • ComputedProperty
    • ContainerDebugAdapter
    • CoreObject
    • DataAdapter
    • Ember.Controller
    • Ember.NativeArray
    • Ember.Templates.helpers
    • Ember.Test
    • Ember.Test.QUnitAdapter
    • EmberArray
    • EmberENV
    • EmberObject
    • EmberRouter
    • Engine
    • EngineInstance
    • EventTarget
    • Evented
    • Factory
    • FactoryManager
    • FullName
    • HashLocation
    • Helper
    • HistoryLocation
    • Location
    • Mixin
    • MutableArray
    • Namespace
    • NoneLocation
    • ObjectProxy
    • Observable
    • Owner
    • Promise
    • PromiseProxyMixin
    • RegisterOptions
    • Renderer
    • Resolver
    • Route
    • RouteInfo
    • RouteInfoWithAttributes
    • RouterService
    • SafeString
    • Service
    • TestAdapter
    • Transition
    • TrustedHTML

Class SafeString public


Defined in: packages/@ember/-internals/glimmer/lib/utils/string.ts:70
Module: @ember/template
Since: v4.12.0

A wrapper around a string that has been marked as safe ("trusted"). When rendered in HTML, Ember will not perform any escaping.

Note:

  1. This does not make the string safe; it means that some code in your application has marked it as safe using the htmlSafe() function.

  2. The only public API for getting a SafeString is calling htmlSafe(). It is not user-constructible.

If a string contains user inputs or other untrusted data, you must sanitize the string before using the htmlSafe 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 { htmlSafe } from '@ember/template';

let someTrustedOrSanitizedString = "<div>Hello!</div>"

htmlSafe(someTrustedorSanitizedString);


On this page

Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.