0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-18 11:41:52 +00:00

Remove PHP4 cruft from URISchemeRegistry.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang 2009-05-13 16:14:57 -04:00
parent 41c9226f3d
commit 24f761d84a

View File

@ -36,21 +36,20 @@ class HTMLPurifier_URISchemeRegistry
*/ */
public function getScheme($scheme, $config, $context) { public function getScheme($scheme, $config, $context) {
if (!$config) $config = HTMLPurifier_Config::createDefault(); if (!$config) $config = HTMLPurifier_Config::createDefault();
$null = null; // for the sake of passing by reference
// important, otherwise attacker could include arbitrary file // important, otherwise attacker could include arbitrary file
$allowed_schemes = $config->get('URI.AllowedSchemes'); $allowed_schemes = $config->get('URI.AllowedSchemes');
if (!$config->get('URI.OverrideAllowedSchemes') && if (!$config->get('URI.OverrideAllowedSchemes') &&
!isset($allowed_schemes[$scheme]) !isset($allowed_schemes[$scheme])
) { ) {
return $null; return;
} }
if (isset($this->schemes[$scheme])) return $this->schemes[$scheme]; if (isset($this->schemes[$scheme])) return $this->schemes[$scheme];
if (!isset($allowed_schemes[$scheme])) return $null; if (!isset($allowed_schemes[$scheme])) return;
$class = 'HTMLPurifier_URIScheme_' . $scheme; $class = 'HTMLPurifier_URIScheme_' . $scheme;
if (!class_exists($class)) return $null; if (!class_exists($class)) return;
$this->schemes[$scheme] = new $class(); $this->schemes[$scheme] = new $class();
return $this->schemes[$scheme]; return $this->schemes[$scheme];
} }