HumHub Documentation (unofficial)

HTMLPurifier_EntityParser
in package

Handles referencing and derefencing character entities

Table of Contents

Properties

$_attrEntitiesRegex  : mixed
Callback regex string for entities in attributes.
$_entity_lookup  : mixed
Reference to entity lookup table.
$_semiOptionalPrefixRegex  : mixed
Tests if the beginning of a string is a semi-optional regex
$_special_dec2str  : mixed
Decimal to parsed string conversion table for special entities.
$_special_ent2dec  : mixed
Stripped entity names to decimal conversion table for special entities.
$_substituteEntitiesRegex  : mixed
Callback regex string for parsing entities.
$_textEntitiesRegex  : mixed
Callback regex string for entities in text.

Methods

__construct()  : mixed
substituteAttrEntities()  : string
Substitute entities with the parsed equivalents. Use this on attribute contents in documents.
substituteNonSpecialEntities()  : string
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.
substituteSpecialEntities()  : string
Substitutes only special entities with their parsed equivalents.
substituteTextEntities()  : string
Substitute entities with the parsed equivalents. Use this on textual data in an HTML document (as opposed to attributes.)
entityCallback()  : string
Callback function for substituteNonSpecialEntities() that does the work.
nonSpecialEntityCallback()  : string
Callback function for substituteNonSpecialEntities() that does the work.
specialEntityCallback()  : string
Callback function for substituteSpecialEntities() that does the work.

Properties

$_attrEntitiesRegex

Callback regex string for entities in attributes.

protected mixed $_attrEntitiesRegex
Tags
type

string

$_entity_lookup

Reference to entity lookup table.

protected mixed $_entity_lookup
Tags
type

HTMLPurifier_EntityLookup

$_semiOptionalPrefixRegex

Tests if the beginning of a string is a semi-optional regex

protected mixed $_semiOptionalPrefixRegex

$_special_dec2str

Decimal to parsed string conversion table for special entities.

protected mixed $_special_dec2str = array(34 => '"', 38 => '&', 39 => "'", 60 => '<', 62 => '>')
Tags
type

array

$_special_ent2dec

Stripped entity names to decimal conversion table for special entities.

protected mixed $_special_ent2dec = array('quot' => 34, 'amp' => 38, 'lt' => 60, 'gt' => 62)
Tags
type

array

$_substituteEntitiesRegex

Callback regex string for parsing entities.

protected mixed $_substituteEntitiesRegex = '/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/'
Tags
type

string

$_textEntitiesRegex

Callback regex string for entities in text.

protected mixed $_textEntitiesRegex
Tags
type

string

Methods

substituteAttrEntities()

Substitute entities with the parsed equivalents. Use this on attribute contents in documents.

public substituteAttrEntities(string $string) : string
Parameters
$string : string

String to have entities parsed.

Return values
string

Parsed string.

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.

public substituteNonSpecialEntities(string $string) : string
Parameters
$string : string

String to have non-special entities parsed.

Return values
string

Parsed string.

substituteSpecialEntities()

Substitutes only special entities with their parsed equivalents.

public substituteSpecialEntities(string $string) : string
Parameters
$string : string

String to have non-special entities parsed.

Tags
notice

We try to avoid calling this function because otherwise, it would have to be called a lot (for every parsed section).

Return values
string

Parsed string.

substituteTextEntities()

Substitute entities with the parsed equivalents. Use this on textual data in an HTML document (as opposed to attributes.)

public substituteTextEntities(string $string) : string
Parameters
$string : string

String to have entities parsed.

Return values
string

Parsed string.

entityCallback()

Callback function for substituteNonSpecialEntities() that does the work.

protected entityCallback(array<string|int, mixed> $matches) : string
Parameters
$matches : array<string|int, mixed>

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 values
string

Replacement string.

nonSpecialEntityCallback()

Callback function for substituteNonSpecialEntities() that does the work.

protected nonSpecialEntityCallback(array<string|int, mixed> $matches) : string
Parameters
$matches : array<string|int, mixed>

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 values
string

Replacement string.

specialEntityCallback()

Callback function for substituteSpecialEntities() that does the work.

protected specialEntityCallback(array<string|int, mixed> $matches) : string

This callback has same syntax as nonSpecialEntityCallback().

Parameters
$matches : array<string|int, mixed>

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 values
string

Replacement string.


        
On this page

Search results