1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?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;
- }
- }
|