Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

(no description)

File Size: 382 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

HTMLPurifier_Lexer:: (12 methods):
  create()
  __construct()
  parseText()
  parseAttr()
  parseData()
  tokenizeHTML()
  escapeCDATA()
  escapeCommentedCDATA()
  removeIEConditional()
  CDATACallback()
  normalize()
  extractBody()


Class: HTMLPurifier_Lexer  - X-Ref

Forgivingly lexes HTML (SGML-style) markup into tokens.

A lexer parses a string of SGML-style markup and converts them into
corresponding tokens.  It doesn't check for well-formedness, although its
internal mechanism may make this automatic (such as the case of
HTMLPurifier_Lexer_DOMLex).  There are several implementations to choose
from.

A lexer is HTML-oriented: it might work with XML, but it's not
recommended, as we adhere to a subset of the specification for optimization
reasons. This might change in the future. Also, most tokenizers are not
expected to handle DTDs or PIs.

This class should not be directly instantiated, but you may use create() to
retrieve a default copy of the lexer.  Being a supertype, this class
does not actually define any implementation, but offers commonly used
convenience functions for subclasses.

create($config)   X-Ref
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.

param: HTMLPurifier_Config $config
return: HTMLPurifier_Lexer

__construct()   X-Ref
No description

parseText($string, $config)   X-Ref
No description

parseAttr($string, $config)   X-Ref
No description

parseData($string, $is_attr, $config)   X-Ref
Parses special entities into the proper characters.

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

param: string $string String character data to be parsed.
return: string Parsed character data.

tokenizeHTML($string, $config, $context)   X-Ref
Lexes an HTML string into tokens.

param: $string String HTML.
param: HTMLPurifier_Config $config
param: HTMLPurifier_Context $context
return: HTMLPurifier_Token[] array representation of HTML.

escapeCDATA($string)   X-Ref
Translates CDATA sections into regular sections (through escaping).

param: string $string HTML string to process.
return: string HTML with CDATA sections escaped.

escapeCommentedCDATA($string)   X-Ref
Special CDATA case that is especially convoluted for <script>

param: string $string HTML string to process.
return: string HTML with CDATA sections escaped.

removeIEConditional($string)   X-Ref
Special Internet Explorer conditional comments should be removed.

param: string $string HTML string to process.
return: string HTML with conditional comments removed.

CDATACallback($matches)   X-Ref
Callback function for escapeCDATA() that does the work.

param: array $matches PCRE matches array, with index 0 the entire match
return: string Escaped internals of the CDATA section.

normalize($html, $config, $context)   X-Ref
Takes a piece of HTML and normalizes it by converting entities, fixing
encoding, extracting bits, and other good stuff.

param: string $html HTML.
param: HTMLPurifier_Config $config
param: HTMLPurifier_Context $context
return: string

extractBody($html)   X-Ref
Takes a string of HTML (fragment or document) and returns the content