trait EscaperTrait

Escaper trait.

Properties

protected array $htmlNamedEntityMap HTML entity map.

Methods

string
escapeHTML(string|null $string, string $charset, bool $doubleEncode = true)

Returns a string that has been escaped for a HTML body context.

string
escapeURL(string|null $string)

Returns a string that has been escaped for a URI or parameter context.

string
attributeEscaper(array $matches)

Escapes characters for use in a HTML attribute context.

string
escapeAttribute(string|null $string, string $charset)

Returns a string that has been escaped for a HTML attribute context.

string
cssEscaper(array $matches)

Escapes characters for use in a CSS context.

string
escapeCSS(string|null $string, string $charset)

Returns a string that has been escaped for a CSS context.

string
javascriptEscaper(array $matches)

Escapes characters for use in a Javascript context.

string
escapeJavascript(string|null $string, string $charset)

Returns a string that has been escaped for a Javascript context.

Details

at line 53
string escapeHTML(string|null $string, string $charset, bool $doubleEncode = true)

Returns a string that has been escaped for a HTML body context.

Parameters

string|null $string String to escape
string $charset Character set
bool $doubleEncode Should existing entities be encoded?

Return Value

string

at line 64
string escapeURL(string|null $string)

Returns a string that has been escaped for a URI or parameter context.

Parameters

string|null $string String to escape

Return Value

string

at line 77
protected string attributeEscaper(array $matches)

Escapes characters for use in a HTML attribute context.

(This method contains code from the SecurityMultiTool library).

Parameters

array $matches Regex matches

Return Value

string

at line 126
string escapeAttribute(string|null $string, string $charset)

Returns a string that has been escaped for a HTML attribute context.

Parameters

string|null $string String to escape
string $charset Character set

Return Value

string

at line 151
protected string cssEscaper(array $matches)

Escapes characters for use in a CSS context.

(This method contains code from the SecurityMultiTool library).

Parameters

array $matches Regex matches

Return Value

string

at line 176
string escapeCSS(string|null $string, string $charset)

Returns a string that has been escaped for a CSS context.

Parameters

string|null $string String to escape
string $charset Character set

Return Value

string

at line 206
protected string javascriptEscaper(array $matches)

Escapes characters for use in a Javascript context.

(This method contains code from the SecurityMultiTool library).

Parameters

array $matches Regex matches

Return Value

string

at line 227
string escapeJavascript(string|null $string, string $charset)

Returns a string that has been escaped for a Javascript context.

Parameters

string|null $string String to escape
string $charset Character set

Return Value

string