ILIAS  release_4-4 Revision
HTMLPurifier_URISchemeRegistry Class Reference

Registry for retrieving specific URI scheme validator objects. More...

+ Collaboration diagram for HTMLPurifier_URISchemeRegistry:

Public Member Functions

 getScheme ($scheme, $config, $context)
 Retrieves a scheme validator object. More...
 
 register ($scheme, $scheme_obj)
 Registers a custom scheme to the cache, bypassing reflection. More...
 

Static Public Member Functions

static instance ($prototype=null)
 Retrieve sole instance of the registry. More...
 

Protected Attributes

 $schemes = array()
 Cache of retrieved schemes. More...
 

Detailed Description

Registry for retrieving specific URI scheme validator objects.

Definition at line 6 of file URISchemeRegistry.php.

Member Function Documentation

◆ getScheme()

HTMLPurifier_URISchemeRegistry::getScheme (   $scheme,
  $config,
  $context 
)

Retrieves a scheme validator object.

Parameters
$schemeString scheme name like http or mailto
$configHTMLPurifier_Config object
$configHTMLPurifier_Context object

Definition at line 37 of file URISchemeRegistry.php.

References HTMLPurifier_Config\createDefault().

37  {
38  if (!$config) $config = HTMLPurifier_Config::createDefault();
39 
40  // important, otherwise attacker could include arbitrary file
41  $allowed_schemes = $config->get('URI.AllowedSchemes');
42  if (!$config->get('URI.OverrideAllowedSchemes') &&
43  !isset($allowed_schemes[$scheme])
44  ) {
45  return;
46  }
47 
48  if (isset($this->schemes[$scheme])) return $this->schemes[$scheme];
49  if (!isset($allowed_schemes[$scheme])) return;
50 
51  $class = 'HTMLPurifier_URIScheme_' . $scheme;
52  if (!class_exists($class)) return;
53  $this->schemes[$scheme] = new $class();
54  return $this->schemes[$scheme];
55  }
static createDefault()
Convenience constructor that creates a default configuration object.
Definition: Config.php:138
+ Here is the call graph for this function:

◆ instance()

static HTMLPurifier_URISchemeRegistry::instance (   $prototype = null)
static

Retrieve sole instance of the registry.

Parameters
$prototypeOptional prototype to overload sole instance with, or bool true to reset to default registry.
Note
Pass a registry object $prototype with a compatible interface and the function will copy it and return it all further times.

Definition at line 16 of file URISchemeRegistry.php.

Referenced by HTMLPurifier_URIDefinition\getDefaultScheme(), and HTMLPurifier_URI\getSchemeObj().

16  {
17  static $instance = null;
18  if ($prototype !== null) {
19  $instance = $prototype;
20  } elseif ($instance === null || $prototype == true) {
21  $instance = new HTMLPurifier_URISchemeRegistry();
22  }
23  return $instance;
24  }
Registry for retrieving specific URI scheme validator objects.
+ Here is the caller graph for this function:

◆ register()

HTMLPurifier_URISchemeRegistry::register (   $scheme,
  $scheme_obj 
)

Registers a custom scheme to the cache, bypassing reflection.

Parameters
$schemeScheme name
$scheme_objHTMLPurifier_URIScheme object

Definition at line 62 of file URISchemeRegistry.php.

62  {
63  $this->schemes[$scheme] = $scheme_obj;
64  }

Field Documentation

◆ $schemes

HTMLPurifier_URISchemeRegistry::$schemes = array()
protected

Cache of retrieved schemes.

Definition at line 29 of file URISchemeRegistry.php.


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