HtmlEscapeMode class

HTML escape modes.

Allows specifying a mode for HTML escaping that depend on the context where the escaped result is going to be used. The relevant contexts are:

  • as text content of an HTML element.
  • as value of a (single- or double-) quoted attribute value.

All modes require escaping of & (ampersand) characters, and may enable escaping of more characters.

Custom escape modes can be created using the HtmlEscapeMode.HtmlEscapeMode constructor.

Constructors

HtmlEscapeMode({String name = "custom", bool escapeLtGt = false, bool escapeQuot = false, bool escapeApos = false, bool escapeSlash = false})
const
Create a custom escaping mode. [...]

Properties

escapeAposbool
final
Whether to escape "'" (apostrophe).
escapeLtGtbool
final
Whether to escape '<' and '>'.
escapeQuotbool
final
Whether to escape '"' (quote).
escapeSlashbool
final
Whether to escape "/" (forward slash, solidus). [...]
hashCodeint
read-only, inherited
The hash code for this object. [...]
runtimeTypeType
read-only, inherited
A representation of the runtime type of the object.

Methods

noSuchMethod(Invocation invocation) → dynamic
inherited
Invoked when a non-existent method or property is accessed. [...]
toString() → String
override
A string representation of this object. [...]

Operators

operator ==(Object other) → bool
inherited
The equality operator. [...]

Constants

attribute → const HtmlEscapeMode
Escaping mode for text going into double-quoted HTML attribute values. [...]
const HtmlEscapeMode._('attribute', true, true, false, false)
element → const HtmlEscapeMode
Escaping mode for text going into HTML element content. [...]
const HtmlEscapeMode._('element', true, false, false, false)
sqAttribute → const HtmlEscapeMode
Escaping mode for text going into single-quoted HTML attribute values. [...]
const HtmlEscapeMode._('attribute', true, false, true, false)
unknown → const HtmlEscapeMode
Default escaping mode which escape all characters. [...]
const HtmlEscapeMode._('unknown', true, true, true, true)

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-convert/HtmlEscapeMode-class.html