0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-03-23 14:27:02 +00:00

[2.1.2] Remove inclusion reflection from URISchemeRegistry

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1395 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-08-26 15:43:17 +00:00
parent c7676afb0d
commit 85cdea0120
3 changed files with 14 additions and 16 deletions

2
NEWS
View File

@ -25,6 +25,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
this out. this out.
- Fix validation errors in configuration form - Fix validation errors in configuration form
- Hammer out a bunch of edge-case bugs in the standalone distribution - Hammer out a bunch of edge-case bugs in the standalone distribution
- Inclusion reflection removed from URISchemeRegistry; you must manually
include any new schema files you wish to use
. Unit test refactoring for one logical test per test function . Unit test refactoring for one logical test per test function
. Config and context parameters in ComplexHarness deprecated: instead, edit . Config and context parameters in ComplexHarness deprecated: instead, edit
the $config and $context member variables the $config and $context member variables

View File

@ -1,5 +1,12 @@
<?php <?php
require_once 'HTMLPurifier/URIScheme/http.php';
require_once 'HTMLPurifier/URIScheme/https.php';
require_once 'HTMLPurifier/URIScheme/mailto.php';
require_once 'HTMLPurifier/URIScheme/ftp.php';
require_once 'HTMLPurifier/URIScheme/nntp.php';
require_once 'HTMLPurifier/URIScheme/news.php';
HTMLPurifier_ConfigSchema::define( HTMLPurifier_ConfigSchema::define(
'URI', 'AllowedSchemes', array( 'URI', 'AllowedSchemes', array(
'http' => true, // "Hypertext Transfer Protocol", nuf' said 'http' => true, // "Hypertext Transfer Protocol", nuf' said
@ -7,7 +14,6 @@ HTMLPurifier_ConfigSchema::define(
// quite useful, but not necessary // quite useful, but not necessary
'mailto' => true,// Email 'mailto' => true,// Email
'ftp' => true, // "File Transfer Protocol" 'ftp' => true, // "File Transfer Protocol"
'irc' => true, // "Internet Relay Chat", usually needs another app
// for Usenet, these two are similar, but distinct // for Usenet, these two are similar, but distinct
'nntp' => true, // individual Netnews articles 'nntp' => true, // individual Netnews articles
'news' => true // newsgroup or individual Netnews articles 'news' => true // newsgroup or individual Netnews articles
@ -54,12 +60,6 @@ class HTMLPurifier_URISchemeRegistry
*/ */
var $schemes = array(); var $schemes = array();
/**
* Directory where scheme objects can be found
* @private
*/
var $_scheme_dir = null;
/** /**
* Retrieves a scheme validator object * Retrieves a scheme validator object
* @param $scheme String scheme name like http or mailto * @param $scheme String scheme name like http or mailto
@ -79,21 +79,16 @@ class HTMLPurifier_URISchemeRegistry
} }
if (isset($this->schemes[$scheme])) return $this->schemes[$scheme]; if (isset($this->schemes[$scheme])) return $this->schemes[$scheme];
if (empty($this->_dir)) $this->_dir = HTMLPURIFIER_PREFIX . '/HTMLPurifier/URIScheme/';
if (!isset($allowed_schemes[$scheme])) return $null; if (!isset($allowed_schemes[$scheme])) return $null;
// this bit of reflection is not very efficient, and a bit
// hacky too
$class = 'HTMLPurifier_URIScheme_' . $scheme; $class = 'HTMLPurifier_URIScheme_' . $scheme;
if (!class_exists($class)) include_once $this->_dir . $scheme . '.php';
if (!class_exists($class)) return $null; if (!class_exists($class)) return $null;
$this->schemes[$scheme] = new $class(); $this->schemes[$scheme] = new $class();
return $this->schemes[$scheme]; return $this->schemes[$scheme];
} }
/** /**
* Registers a custom scheme to the cache. * Registers a custom scheme to the cache, bypassing reflection.
* @param $scheme Scheme name * @param $scheme Scheme name
* @param $scheme_obj HTMLPurifier_URIScheme object * @param $scheme_obj HTMLPurifier_URIScheme object
*/ */

View File

@ -174,8 +174,9 @@ function copy_and_remove_includes($file, $sfile) {
*/ */
function replace_includes_callback($matches) { function replace_includes_callback($matches) {
$file = $matches[1]; $file = $matches[1];
// PHP 5 only file // PHP 5 only file / PEAR files
if ($file == 'HTMLPurifier/Lexer/DOMLex.php' || $file == 'HTMLPurifier/Printer.php') { $preserve = array('HTMLPurifier/Lexer/DOMLex.php'=>1, 'HTMLPurifier/Printer.php'=>1, 'XML/HTMLSax3.php'=>1);
if (isset($preserve[$file])) {
return $matches[0]; return $matches[0];
} }
if (isset($GLOBALS['loaded'][$file])) return ''; if (isset($GLOBALS['loaded'][$file])) return '';
@ -205,8 +206,8 @@ make_dir_standalone('HTMLPurifier/EntityLookup');
make_dir_standalone('HTMLPurifier/Language'); make_dir_standalone('HTMLPurifier/Language');
make_file_standalone('HTMLPurifier/Printer.php'); make_file_standalone('HTMLPurifier/Printer.php');
make_dir_standalone('HTMLPurifier/Printer'); make_dir_standalone('HTMLPurifier/Printer');
make_dir_standalone('HTMLPurifier/URIScheme');
make_dir_standalone('HTMLPurifier/Filter'); make_dir_standalone('HTMLPurifier/Filter');
make_file_standalone('HTMLPurifier/Lexer/PEARSax3.php'); // not incl by default
// PHP 5 only files // PHP 5 only files
make_file_standalone('HTMLPurifier/Lexer/DOMLex.php'); make_file_standalone('HTMLPurifier/Lexer/DOMLex.php');
make_file_standalone('HTMLPurifier/Lexer/PH5P.php'); make_file_standalone('HTMLPurifier/Lexer/PH5P.php');