ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
string$schemeString scheme name like http or mailto
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
HTMLPurifier_URIScheme

Definition at line 41 of file URISchemeRegistry.php.

References $config, and HTMLPurifier_Config\createDefault().

42  {
43  if (!$config) {
45  }
46 
47  // important, otherwise attacker could include arbitrary file
48  $allowed_schemes = $config->get('URI.AllowedSchemes');
49  if (!$config->get('URI.OverrideAllowedSchemes') &&
50  !isset($allowed_schemes[$scheme])
51  ) {
52  return;
53  }
54 
55  if (isset($this->schemes[$scheme])) {
56  return $this->schemes[$scheme];
57  }
58  if (!isset($allowed_schemes[$scheme])) {
59  return;
60  }
61 
62  $class = 'HTMLPurifier_URIScheme_' . $scheme;
63  if (!class_exists($class)) {
64  return;
65  }
66  $this->schemes[$scheme] = new $class();
67  return $this->schemes[$scheme];
68  }
static createDefault()
Convenience constructor that creates a default configuration object.
Definition: Config.php:154
+ Here is the call graph for this function:

◆ instance()

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

Retrieve sole instance of the registry.

Parameters
HTMLPurifier_URISchemeRegistry$prototypeOptional prototype to overload sole instance with, or bool true to reset to default registry.
Returns
HTMLPurifier_URISchemeRegistry
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 17 of file URISchemeRegistry.php.

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

18  {
19  static $instance = null;
20  if ($prototype !== null) {
21  $instance = $prototype;
22  } elseif ($instance === null || $prototype == true) {
23  $instance = new HTMLPurifier_URISchemeRegistry();
24  }
25  return $instance;
26  }
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
string$schemeScheme name
HTMLPurifier_URIScheme$scheme_obj

Definition at line 75 of file URISchemeRegistry.php.

76  {
77  $this->schemes[$scheme] = $scheme_obj;
78  }

Field Documentation

◆ $schemes

HTMLPurifier_URISchemeRegistry::$schemes = array()
protected

Cache of retrieved schemes.

HTMLPurifier_URIScheme[]

Definition at line 32 of file URISchemeRegistry.php.


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