Class HTMLPurifier_EntityParser

InheritanceHTMLPurifier_EntityParser

Handles referencing and derefencing character entities

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_entity_lookup Reference to entity lookup table. HTMLPurifier_EntityParser
$_special_dec2str Decimal to parsed string conversion table for special entities. HTMLPurifier_EntityParser
$_special_ent2dec Stripped entity names to decimal conversion table for special entities. HTMLPurifier_EntityParser
$_substituteEntitiesRegex Callback regex string for parsing entities. HTMLPurifier_EntityParser

Public Methods

Hide inherited methods

MethodDescriptionDefined By
substituteNonSpecialEntities() Substitutes non-special entities with their parsed equivalents. Since running this whenever you have parsed character is t3h 5uck, we run it before everything else. HTMLPurifier_EntityParser
substituteSpecialEntities() Substitutes only special entities with their parsed equivalents. HTMLPurifier_EntityParser

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
nonSpecialEntityCallback() Callback function for substituteNonSpecialEntities() that does the work. HTMLPurifier_EntityParser
specialEntityCallback() Callback function for substituteSpecialEntities() that does the work. HTMLPurifier_EntityParser

Property Details

$_entity_lookup protected property
protected $_entity_lookup null
$_special_dec2str protected property
protected $_special_dec2str = [34 => '"'38 => '&'39 => "'"60 => '<'62 => '>']
$_special_ent2dec protected property
protected $_special_ent2dec = ['quot' => 34'amp' => 38'lt' => 60'gt' => 62]
$_substituteEntitiesRegex protected property
protected $_substituteEntitiesRegex '/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/'

Method Details

nonSpecialEntityCallback() protected method

Callback function for substituteNonSpecialEntities() that does the work.

protected string nonSpecialEntityCallback ( $matches )
$matches array

PCRE matches array, with 0 the entire match, and

             either index 1, 2 or 3 set with a hex value, dec value,
             or string (respectively).
return string

Replacement string.

specialEntityCallback() protected method

Callback function for substituteSpecialEntities() that does the work.

This callback has same syntax as nonSpecialEntityCallback().

protected string specialEntityCallback ( $matches )
$matches array

PCRE-style matches array, with 0 the entire match, and

             either index 1, 2 or 3 set with a hex value, dec value,
             or string (respectively).
return string

Replacement string.

substituteNonSpecialEntities() public method

Substitutes non-special entities with their parsed equivalents. Since running this whenever you have parsed character is t3h 5uck, we run it before everything else.

public string substituteNonSpecialEntities ( $string )
$string string

String to have non-special entities parsed.

return string

Parsed string.

substituteSpecialEntities() public method

Substitutes only special entities with their parsed equivalents.

public string substituteSpecialEntities ( $string )
$string string

String to have non-special entities parsed.

return string

Parsed string.