Class E
Context specific methods for use in secure output escaping
The escape is derived from code of the Zend Framework 2.1.5 - 2.2.2
- Wei\Base
-
Wei\E
Link: https://github.com/zendframework/zf2/blob/master/library/Zend/Escaper/Escaper.php
Located at E.php
public
|
#
__construct( array $options = array() )
Constructor: Single parameter allows setting of global encoding for use by the current object. If PHP 5.4 is detected, additional ENT_SUBSTITUTE flag is set for htmlspecialchars() calls. |
public
string
|
|
public
string
|
|
public
string
|
|
public
string
|
#
js( string $string )
Escape a string for the Javascript context. This does not use json_encode(). An extended set of characters are escaped beyond ECMAScript's rules for Javascript literal string escaping in order to prevent misinterpretation of Javascript as HTML leading to the injection of special characters and entities. The escaping used should be tolerant of cases where HTML escaping was not applied on top of Javascript escaping correctly. Backslash escaping is not used as it still leaves the escaped character as-is and so is not useful in a HTML context. |
public
string
|
|
public
string
|
|
protected
string
|
#
htmlAttrMatcher( array $matches )
Callback function for preg_replace_callback that applies HTML Attribute escaping to all matches. |
protected
string
|
|
protected
string
|
#
cssMatcher( array $matches )
Callback function for preg_replace_callback that applies CSS escaping to all matches. |
protected
string
|
|
protected
string
|
|
protected
boolean
|
|
protected
string
|
#
convertEncoding( string $string, string $to, array|string $from )
Encoding conversion helper which wraps iconv and mbstring where they exist or throws and exception where neither is available. |
public
string
|
__call(),
__get(),
getOption(),
setOption()
|
protected static
array
|
$htmlNamedEntityMap
Entity Map mapping Unicode codepoints to any available named HTML entities. |
#
array(
34 => 'quot', // quotation mark
38 => 'amp', // ampersand
60 => 'lt', // less-than sign
62 => 'gt', // greater-than sign
)
|
protected
string
|
$encoding
Current encoding for escaping. If not UTF-8, we convert strings from this encoding pre-escaping and back to this encoding post-escaping. |
#
'utf-8'
|
protected
string
|
$htmlSpecialCharsFlags
Holds the value of the special flags passed as second parameter to htmlspecialchars(). We modify these for PHP 5.4 to take advantage of the new ENT_SUBSTITUTE flag for correctly dealing with invalid UTF-8 sequences. |
#
ENT_QUOTES
|
protected
callable
|
$htmlAttrMatcher
Static Matcher which escapes characters for HTML Attribute contexts |
|
protected
callable
|
$jsMatcher
Static Matcher which escapes characters for Javascript contexts |
|
protected
callable
|
$cssMatcher
Static Matcher which escapes characters for CSS Attribute contexts |
|
protected
array
|
$supportedEncodings
List of all encoding supported by this class |
#
array(
'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5',
'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866',
'ibm866', '866', 'cp1251', 'windows-1251',
'win-1251', '1251', 'cp1252', 'windows-1252',
'1252', 'koi8-r', 'koi8-ru', 'koi8r',
'big5', '950', 'gb2312', '936',
'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win',
'cp932', '932', 'euc-jp', 'eucjp',
'eucjp-win', 'macroman'
)
|
$providers,
$wei
|