Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
HTMLPurifier_Lexer_DOMLex Class Reference
Inheritance diagram for HTMLPurifier_Lexer_DOMLex:
HTMLPurifier_Lexer HTMLPurifier_Lexer_PH5P

Public Member Functions

 callbackArmorCommentEntities ($matches)
 Callback function that entity-izes ampersands in comments so that callbackUndoCommentSubst doesn't clobber them.
 
 callbackUndoCommentSubst ($matches)
 Callback function for undoing escaping of stray angled brackets in comments.
 
 extractBody ($html)
 Takes a string of HTML (fragment or document) and returns the content.
 
 muteErrorHandler ($errno, $errstr)
 An error handler that mutes all errors.
 
 normalize ($html, $config, $context)
 Takes a piece of HTML and normalizes it by converting entities, fixing encoding, extracting bits, and other good stuff.
 
 parseAttr ($string, $config)
 
 parseData ($string, $is_attr, $config)
 Parses special entities into the proper characters.
 
 parseText ($string, $config)
 
 tokenizeHTML ($html, $config, $context)
 

Static Public Member Functions

static create ($config)
 Retrieves or sets the default Lexer as a Prototype Factory.
 

Public Attributes

 $tracksLineNumbers = false
 Whether or not this lexer implements line-number/column-number tracking.
 

Protected Member Functions

 createEndNode ($node, &$tokens)
 
 createStartNode ($node, &$tokens, $collect, $config)
 
 getData ($node)
 Portably retrieve the data of a node; deals with older versions of libxml like 2.7.6.
 
 getTagName ($node)
 Portably retrieve the tag name of a node; deals with older versions of libxml like 2.7.6.
 
 tokenizeDOM ($node, &$tokens, $config)
 Iterative function that tokenizes a node, putting it into an accumulator.
 
 transformAttrToAssoc ($node_map)
 Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.
 
 wrapHTML ($html, $config, $context, $use_div=true)
 Wraps an HTML fragment in the necessary HTML.
 

Static Protected Member Functions

static CDATACallback ($matches)
 Callback function for escapeCDATA() that does the work.
 
static escapeCDATA ($string)
 Translates CDATA sections into regular sections (through escaping).
 
static escapeCommentedCDATA ($string)
 Special CDATA case that is especially convoluted for <script>
 
static removeIEConditional ($string)
 Special Internet Explorer conditional comments should be removed.
 

Protected Attributes

 $_special_entity2str
 Most common entity to raw value conversion table for special entities.
 

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_Lexer_DOMLex::__construct ( )

Reimplemented from HTMLPurifier_Lexer.

Member Function Documentation

◆ callbackArmorCommentEntities()

HTMLPurifier_Lexer_DOMLex::callbackArmorCommentEntities ( $matches)

Callback function that entity-izes ampersands in comments so that callbackUndoCommentSubst doesn't clobber them.

Parameters
array$matches
Return values
string

◆ callbackUndoCommentSubst()

HTMLPurifier_Lexer_DOMLex::callbackUndoCommentSubst ( $matches)

Callback function for undoing escaping of stray angled brackets in comments.

Parameters
array$matches
Return values
string

◆ CDATACallback()

static HTMLPurifier_Lexer::CDATACallback ( $matches)
staticprotectedinherited

Callback function for escapeCDATA() that does the work.

Warning
Though this is public in order to let the callback happen, calling it directly is not recommended.
Parameters
array$matchesPCRE matches array, with index 0 the entire match and 1 the inside of the CDATA section.
Return values
stringEscaped internals of the CDATA section.

◆ create()

static HTMLPurifier_Lexer::create ( $config)
staticinherited

Retrieves or sets the default Lexer as a Prototype Factory.

By default HTMLPurifier_Lexer_DOMLex will be returned. There are a few exceptions involving special features that only DirectLex implements.

Note
The behavior of this class has changed, rather than accepting a prototype object, it now accepts a configuration object. To specify your own prototype, set Core.LexerImpl to it. This change in behavior de-singletonizes the lexer object.
Parameters
HTMLPurifier_Config$config
Return values
HTMLPurifier_Lexer
Exceptions
HTMLPurifier_Exception

◆ createEndNode()

HTMLPurifier_Lexer_DOMLex::createEndNode ( $node,
& $tokens )
protected
Parameters
DOMNode$node
HTMLPurifier_Token[]$tokens

◆ createStartNode()

HTMLPurifier_Lexer_DOMLex::createStartNode ( $node,
& $tokens,
$collect,
$config )
protected
Parameters
DOMNode$nodeDOMNode to be tokenized.
HTMLPurifier_Token[]$tokensArray-list of already tokenized tokens.
bool$collectSays whether or start and close are collected, set to false at first recursion because it's the implicit DIV tag you're dealing with.
Return values
boolif the token needs an endtoken
Todo
data and tagName properties don't seem to exist in DOMNode?

◆ escapeCDATA()

static HTMLPurifier_Lexer::escapeCDATA ( $string)
staticprotectedinherited

Translates CDATA sections into regular sections (through escaping).

Parameters
string$stringHTML string to process.
Return values
stringHTML with CDATA sections escaped.

◆ escapeCommentedCDATA()

static HTMLPurifier_Lexer::escapeCommentedCDATA ( $string)
staticprotectedinherited

Special CDATA case that is especially convoluted for <script>

Parameters
string$stringHTML string to process.
Return values
stringHTML with CDATA sections escaped.

◆ extractBody()

HTMLPurifier_Lexer::extractBody ( $html)
inherited

Takes a string of HTML (fragment or document) and returns the content.

Todo
Consider making protected

◆ getData()

HTMLPurifier_Lexer_DOMLex::getData ( $node)
protected

Portably retrieve the data of a node; deals with older versions of libxml like 2.7.6.

Parameters
DOMNode$node

◆ getTagName()

HTMLPurifier_Lexer_DOMLex::getTagName ( $node)
protected

Portably retrieve the tag name of a node; deals with older versions of libxml like 2.7.6.

Parameters
DOMNode$node

◆ muteErrorHandler()

HTMLPurifier_Lexer_DOMLex::muteErrorHandler ( $errno,
$errstr )

An error handler that mutes all errors.

Parameters
int$errno
string$errstr

◆ normalize()

HTMLPurifier_Lexer::normalize ( $html,
$config,
$context )
inherited

Takes a piece of HTML and normalizes it by converting entities, fixing encoding, extracting bits, and other good stuff.

Parameters
string$htmlHTML.
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Return values
string
Todo
Consider making protected

◆ parseData()

HTMLPurifier_Lexer::parseData ( $string,
$is_attr,
$config )
inherited

Parses special entities into the proper characters.

This string will translate escaped versions of the special characters into the correct ones.

Parameters
string$stringString character data to be parsed.
Return values
stringParsed character data.

◆ removeIEConditional()

static HTMLPurifier_Lexer::removeIEConditional ( $string)
staticprotectedinherited

Special Internet Explorer conditional comments should be removed.

Parameters
string$stringHTML string to process.
Return values
stringHTML with conditional comments removed.

◆ tokenizeDOM()

HTMLPurifier_Lexer_DOMLex::tokenizeDOM ( $node,
& $tokens,
$config )
protected

Iterative function that tokenizes a node, putting it into an accumulator.

To iterate is human, to recurse divine - L. Peter Deutsch

Parameters
DOMNode$nodeDOMNode to be tokenized.
HTMLPurifier_Token[]$tokensArray-list of already tokenized tokens.
Return values
HTMLPurifier_Tokenof node appended to previously passed tokens.

◆ tokenizeHTML()

HTMLPurifier_Lexer_DOMLex::tokenizeHTML ( $html,
$config,
$context )
Parameters
string$html
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Return values
HTMLPurifier_Token[]

Reimplemented from HTMLPurifier_Lexer.

Reimplemented in HTMLPurifier_Lexer_PH5P.

◆ transformAttrToAssoc()

HTMLPurifier_Lexer_DOMLex::transformAttrToAssoc ( $node_map)
protected

Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.

Parameters
DOMNamedNodeMap$node_mapDOMNamedNodeMap of DOMAttr objects.
Return values
arrayAssociative array of attributes.

◆ wrapHTML()

HTMLPurifier_Lexer_DOMLex::wrapHTML ( $html,
$config,
$context,
$use_div = true )
protected

Wraps an HTML fragment in the necessary HTML.

Parameters
string$html
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Return values
string

Member Data Documentation

◆ $_special_entity2str

HTMLPurifier_Lexer::$_special_entity2str
protectedinherited
Initial value:
=
array(
'&quot;' => '"',
'&amp;' => '&',
'&lt;' => '<',
'&gt;' => '>',
'&#39;' => "'",
'&#039;' => "'",
'&#x27;' => "'"
)

Most common entity to raw value conversion table for special entities.

@type array

◆ $tracksLineNumbers

HTMLPurifier_Lexer::$tracksLineNumbers = false
inherited

Whether or not this lexer implements line-number/column-number tracking.

If it does, set to true.


The documentation for this class was generated from the following file: