W3cubDocs

/Phalcon 2

Class Phalcon\Escaper

implements Phalcon\EscaperInterface

Escapes different kinds of text securing them. By using this component you may prevent XSS attacks. This component only works with UTF-8. The PREG extension needs to be compiled with UTF-8 support.

$escaper = new Phalcon\Escaper();
$escaped = $escaper->escapeCss("font-family: <Verdana>");
echo $escaped; // font\2D family\3A \20 \3C Verdana\3E

Methods

public setEncoding (string $encoding)

Sets the encoding to be used by the escaper

$escaper->setEncoding('utf-8');

public string getEncoding ()

Returns the internal encoding used by the escaper

public setHtmlQuoteType (int $quoteType)

Sets the HTML quoting type for htmlspecialchars

$escaper->setHtmlQuoteType(ENT_XHTML);

public string detectEncoding (string $str)

Detect the character encoding of a string to be handled by an encoder Special-handling for chr(172) and chr(128) to chr(159) which fail to be detected by mb_detect_encoding()

public string normalizeEncoding (string $str)

Utility to normalize a string’s encoding to UTF-32.

public string escapeHtml (string $text)

Escapes a HTML string. Internally uses htmlspecialchars

public string escapeHtmlAttr (unknown $text)

Escapes a HTML attribute string

public string escapeCss (string $css)

Escape CSS strings by replacing non-alphanumeric chars by their hexadecimal escaped representation

public string escapeJs (string $js)

Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation

public string escapeUrl (string $url)

Escapes a URL. Internally uses rawurlencode

© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Escaper.html