Claro_Html_Sanitizer Class Reference

Public Member Functions

 __construct ()
 resetAll ()
 addAdditionalTags ($tags)
 allowObjects ()
 allowDOMEvents ()
 allowScript ()
 allowJavascriptInUrls ()
 allowStyle ()
 allowAllJavascript ()
 allowAll ()
 sanitize ($html)

Protected Member Functions

 filterHTTPResponseSplitting ($url)
 removeJavascriptURL ($str)
 sanitizeURL ($url)
 _sanitizeURLCallback ($matches)
 sanitizeHref ($str)
 _sanitizeSrcCallback ($matches)
 sanitizeSrc ($str)
 removeEvilAttributes ($str)
 removeDOMEvents ($str)
 _removeDOMEventsCallback ($matches)
 removeStyle ($str)
 _removeStyleCallback ($matches)
 removeEvilTags ($str)
 _stripTags ($str, $tagList)

Protected Attributes

 $_allowedTags
 $_allowJavascriptEvents
 $_allowJavascriptInUrls
 $_allowObjects
 $_allowScript
 $_allowStyle
 $_allowInlineStyle
 $_additionalTags

Detailed Description

Sanitize HTML body content Remove dangerous tags and attributes that can lead to security issues like XSS or HTTP response splitting

Definition at line 18 of file htmlsanitizer.lib.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

Definition at line 33 of file htmlsanitizer.lib.php.


Member Function Documentation

_removeDOMEventsCallback ( matches  )  [protected]

Callback for PCRE

Parameters:
array $matches
Returns:
string
See also:
removeDOMEvents

Definition at line 275 of file htmlsanitizer.lib.php.

_removeStyleCallback ( matches  )  [protected]

Callback for PCRE

Parameters:
array $matches
Returns:
string
See also:
removeStyle

Definition at line 305 of file htmlsanitizer.lib.php.

_sanitizeSrcCallback ( matches  )  [protected]

Callback for PCRE

Parameters:
array $matches
Returns:
string
See also:
sanitizeURL

Definition at line 205 of file htmlsanitizer.lib.php.

_sanitizeURLCallback ( matches  )  [protected]

Callback for PCRE

Parameters:
array $matches
Returns:
string
See also:
sanitizeURL

Definition at line 180 of file htmlsanitizer.lib.php.

_stripTags ( str,
tagList 
) [protected]

Remove unwanted tags

Parameters:
string $str html
string $tagList allowed tag list

Definition at line 349 of file htmlsanitizer.lib.php.

addAdditionalTags ( tags  ) 

Add additional tags to allowed tags

Parameters:
string $tags

Definition at line 65 of file htmlsanitizer.lib.php.

allowAll (  ) 

Allow all tags and attributes

Definition at line 123 of file htmlsanitizer.lib.php.

allowAllJavascript (  ) 

Helper to allow all javascript related tags and attributes

Definition at line 113 of file htmlsanitizer.lib.php.

allowDOMEvents (  ) 

Allow DOM event on DOM elements

Definition at line 81 of file htmlsanitizer.lib.php.

allowJavascriptInUrls (  ) 

Allow the use of javascript: in urls

Definition at line 97 of file htmlsanitizer.lib.php.

allowObjects (  ) 

Allow object, embed, applet and param tags in html

Definition at line 73 of file htmlsanitizer.lib.php.

allowScript (  ) 

Allow script tags

Definition at line 89 of file htmlsanitizer.lib.php.

allowStyle (  ) 

Allow style tags and attributes

Definition at line 105 of file htmlsanitizer.lib.php.

filterHTTPResponseSplitting ( url  )  [protected]

Filter URLs to avoid HTTP response splitting attacks

Parameters:
string $url
Returns:
string filtered url

Definition at line 135 of file htmlsanitizer.lib.php.

removeDOMEvents ( str  )  [protected]

Remove DOM events attributes from html tags

Parameters:
string $str html tag
Returns:
string filtered html tag

Definition at line 253 of file htmlsanitizer.lib.php.

removeEvilAttributes ( str  )  [protected]

Remove dangerous attributes from html tags

Parameters:
string $str html tag
Returns:
string filtered html tag

Definition at line 229 of file htmlsanitizer.lib.php.

removeEvilTags ( str  )  [protected]

Remove dangerous HTML tags private

Parameters:
string $str html code
Returns:
string filtered url

Definition at line 316 of file htmlsanitizer.lib.php.

removeJavascriptURL ( str  )  [protected]

Remove potential javascript in urls

Parameters:
string $url
Returns:
string filtered url

Definition at line 146 of file htmlsanitizer.lib.php.

removeStyle ( str  )  [protected]

Remove style attributes from html tags

Parameters:
string $str html tag
Returns:
string filtered html tag

Definition at line 285 of file htmlsanitizer.lib.php.

resetAll (  ) 

(re)set all options to default value

Definition at line 41 of file htmlsanitizer.lib.php.

sanitize ( html  ) 

Sanitize HTML remove dangerous tags and attributes clean urls

Parameters:
string $html html code
Returns:
string sanitized html code

Definition at line 384 of file htmlsanitizer.lib.php.

sanitizeHref ( str  )  [protected]

Remove potential flaws in href attributes

Parameters:
string $str html tag
Returns:
string filtered html tag

Definition at line 190 of file htmlsanitizer.lib.php.

sanitizeSrc ( str  )  [protected]

Remove potential flaws in href attributes

Parameters:
string $str html tag
Returns:
string filtered html tag

Definition at line 215 of file htmlsanitizer.lib.php.

sanitizeURL ( url  )  [protected]

Remove potential flaws in urls

Parameters:
string $url
Returns:
string filtered url

Definition at line 162 of file htmlsanitizer.lib.php.


Field Documentation

$_additionalTags [protected]

Definition at line 28 of file htmlsanitizer.lib.php.

$_allowedTags [protected]

Definition at line 21 of file htmlsanitizer.lib.php.

$_allowInlineStyle [protected]

Definition at line 27 of file htmlsanitizer.lib.php.

$_allowJavascriptEvents [protected]

Definition at line 22 of file htmlsanitizer.lib.php.

$_allowJavascriptInUrls [protected]

Definition at line 23 of file htmlsanitizer.lib.php.

$_allowObjects [protected]

Definition at line 24 of file htmlsanitizer.lib.php.

$_allowScript [protected]

Definition at line 25 of file htmlsanitizer.lib.php.

$_allowStyle [protected]

Definition at line 26 of file htmlsanitizer.lib.php.


The documentation for this class was generated from the following file:
Generated on Tue Jun 8 12:28:38 2010 for Claroline API by  doxygen 1.6.3