123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- class HTMLPurifier_URISchemeRegistry
- {
-
- public static function instance($prototype = null)
- {
- static $instance = null;
- if ($prototype !== null) {
- $instance = $prototype;
- } elseif ($instance === null || $prototype == true) {
- $instance = new HTMLPurifier_URISchemeRegistry();
- }
- return $instance;
- }
-
- protected $schemes = array();
-
- public function getScheme($scheme, $config, $context)
- {
- if (!$config) {
- $config = HTMLPurifier_Config::createDefault();
- }
-
- $allowed_schemes = $config->get('URI.AllowedSchemes');
- if (!$config->get('URI.OverrideAllowedSchemes') &&
- !isset($allowed_schemes[$scheme])
- ) {
- return;
- }
- if (isset($this->schemes[$scheme])) {
- return $this->schemes[$scheme];
- }
- if (!isset($allowed_schemes[$scheme])) {
- return;
- }
- $class = 'HTMLPurifier_URIScheme_' . $scheme;
- if (!class_exists($class)) {
- return;
- }
- $this->schemes[$scheme] = new $class();
- return $this->schemes[$scheme];
- }
-
- public function register($scheme, $scheme_obj)
- {
- $this->schemes[$scheme] = $scheme_obj;
- }
- }
|