ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
Sanitizer Class Reference
+ Collaboration diagram for Sanitizer:

Static Public Member Functions

static decodeCharReferences ($text)
 Decode any character references, numeric or named entities, in the text and return a UTF-8 string. More...
 
static decodeCharReferencesCallback ($matches)
 
static decodeChar ($codepoint)
 Return UTF-8 string for a codepoint if that is a valid character reference, otherwise U+FFFD REPLACEMENT CHARACTER. More...
 
static decodeEntity ($name)
 If the named entity is defined in the HTML 4.0/XHTML 1.0 DTD, return the UTF-8 encoding of that character. More...
 

Static Private Member Functions

static validateCodepoint ($codepoint)
 Returns true if a given Unicode codepoint is a valid character in XML. More...
 

Detailed Description

Definition at line 348 of file Sanitizer.php.

Member Function Documentation

◆ decodeChar()

static Sanitizer::decodeChar (   $codepoint)
static

Return UTF-8 string for a codepoint if that is a valid character reference, otherwise U+FFFD REPLACEMENT CHARACTER.

Parameters
int$codepoint
Returns
string

Definition at line 409 of file Sanitizer.php.

414 {
415 if (Sanitizer::validateCodepoint($codepoint)) {
416 return "";
417 //return codepointToUtf8($codepoint);
static validateCodepoint($codepoint)
Returns true if a given Unicode codepoint is a valid character in XML.
Definition: Sanitizer.php:355

◆ decodeCharReferences()

static Sanitizer::decodeCharReferences (   $text)
static

Decode any character references, numeric or named entities, in the text and return a UTF-8 string.

Parameters
string$text
Returns
string

Definition at line 374 of file Sanitizer.php.

379 {
380 return preg_replace_callback(
const MW_CHAR_REFS_REGEX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Sanitizer.php:23

Referenced by Title\newFromText().

+ Here is the caller graph for this function:

◆ decodeCharReferencesCallback()

static Sanitizer::decodeCharReferencesCallback (   $matches)
static
Parameters
string$matches
Returns
string

Definition at line 387 of file Sanitizer.php.

392 {
393 if ($matches[1] != '') {
394 return Sanitizer::decodeEntity($matches[1]);
395 } elseif ($matches[2] != '') {
396 return Sanitizer::decodeChar(intval($matches[2]));
397 } elseif ($matches[3] != '') {
398 return Sanitizer::decodeChar(hexdec($matches[3]));
399 } elseif ($matches[4] != '') {
400 return Sanitizer::decodeChar(hexdec($matches[4]));
static decodeChar($codepoint)
Return UTF-8 string for a codepoint if that is a valid character reference, otherwise U+FFFD REPLACEM...
Definition: Sanitizer.php:409
static decodeEntity($name)
If the named entity is defined in the HTML 4.0/XHTML 1.0 DTD, return the UTF-8 encoding of that chara...
Definition: Sanitizer.php:427

◆ decodeEntity()

static Sanitizer::decodeEntity (   $name)
static

If the named entity is defined in the HTML 4.0/XHTML 1.0 DTD, return the UTF-8 encoding of that character.

Otherwise, returns pseudo-entity source (eg &foo;)

Parameters
string$name
Returns
string

Definition at line 427 of file Sanitizer.php.

432 {
434
435 if (isset($wgHtmlEntityAliases[$name])) {
436 $name = $wgHtmlEntityAliases[$name];
437 }
438 if (isset($wgHtmlEntities[$name])) {
439 return "";
440 //return codepointToUtf8($wgHtmlEntities[$name]);
global $wgHtmlEntities
List of all named character entities defined in HTML 4.01 http://www.w3.org/TR/html4/sgml/entities....
Definition: Sanitizer.php:56
global $wgHtmlEntityAliases
Character entity aliases accepted by MediaWiki.
Definition: Sanitizer.php:314

◆ validateCodepoint()

static Sanitizer::validateCodepoint (   $codepoint)
staticprivate

Returns true if a given Unicode codepoint is a valid character in XML.

Parameters
int$codepoint
Returns
bool

Definition at line 355 of file Sanitizer.php.

360 {
361 return ($codepoint == 0x09)
362 || ($codepoint == 0x0a)
363 || ($codepoint == 0x0d)

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