ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
URISchemeRegistry.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
16  public static function instance($prototype = null) {
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  }
25 
29  protected $schemes = array();
30 
37  public function getScheme($scheme, $config, $context) {
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  }
56 
62  public function register($scheme, $scheme_obj) {
63  $this->schemes[$scheme] = $scheme_obj;
64  }
65 
66 }
67 
68 // vim: et sw=4 sts=4