| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: |
|
| 6: | class HTMLPurifier_URISchemeRegistry
|
| 7: | {
|
| 8: |
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | public static function instance($prototype = null)
|
| 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: | }
|
| 27: |
|
| 28: | |
| 29: | |
| 30: | |
| 31: |
|
| 32: | protected $schemes = array();
|
| 33: |
|
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: |
|
| 41: | public function getScheme($scheme, $config, $context)
|
| 42: | {
|
| 43: | if (!$config) {
|
| 44: | $config = HTMLPurifier_Config::createDefault();
|
| 45: | }
|
| 46: |
|
| 47: |
|
| 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: | }
|
| 69: |
|
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: |
|
| 75: | public function register($scheme, $scheme_obj)
|
| 76: | {
|
| 77: | $this->schemes[$scheme] = $scheme_obj;
|
| 78: | }
|
| 79: | }
|
| 80: |
|
| 81: |
|
| 82: | |