1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 22:26:31 +02:00

Compare commits

..

20 Commits

Author SHA1 Message Date
Edward Z. Yang
9db861e356 Release 2.1.3, merged in 1404 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1444 48356398-32a2-884e-a903-53898d9a118a
2007-11-06 04:34:33 +00:00
Edward Z. Yang
b3f0e6c86c Release 2.1.2, merged in 1368 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1404 48356398-32a2-884e-a903-53898d9a118a
2007-09-03 15:40:43 +00:00
Edward Z. Yang
80c60bb9b5 Release 2.1.0, merged in 1255 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1368 48356398-32a2-884e-a903-53898d9a118a
2007-08-05 02:02:46 +00:00
Edward Z. Yang
503e76081b Revert to 2.0.1, it appears that the 2.1.0 merge was done improperly.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1367 48356398-32a2-884e-a903-53898d9a118a
2007-08-05 01:42:52 +00:00
Edward Z. Yang
678a593e62 Release 2.1.0, merged in 1313 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1352 48356398-32a2-884e-a903-53898d9a118a
2007-08-03 03:20:49 +00:00
Edward Z. Yang
495164e938 Release 2.0.1, merged in 1181 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1255 48356398-32a2-884e-a903-53898d9a118a
2007-06-27 14:30:45 +00:00
Edward Z. Yang
42858ad594 Finish up with a few more files that didn't get updated. Hrmm..
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1181 48356398-32a2-884e-a903-53898d9a118a
2007-06-21 00:53:09 +00:00
Edward Z. Yang
5ecb11f19a Tack on missing basic smoketests.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1180 48356398-32a2-884e-a903-53898d9a118a
2007-06-21 00:42:00 +00:00
Edward Z. Yang
0101311193 Release 2.0.0, merged in 1026 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1179 48356398-32a2-884e-a903-53898d9a118a
2007-06-21 00:36:12 +00:00
Edward Z. Yang
c35eb3e95f Release 1.6.1, merged in 931 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1026 48356398-32a2-884e-a903-53898d9a118a
2007-05-05 20:49:49 +00:00
Edward Z. Yang
b829e76bbf Release 1.6.0, merged in r875-930.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@931 48356398-32a2-884e-a903-53898d9a118a
2007-04-02 03:09:23 +00:00
Edward Z. Yang
e967680250 Really release 1.5.0.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@876 48356398-32a2-884e-a903-53898d9a118a
2007-03-24 02:19:11 +00:00
Edward Z. Yang
dd2fd06591 Release 1.5.0, merged in r688-867.
- LanguageFactory::instance() declared static
- HTMLModuleManagerTest pass by reference bug fixed, merge back into trunk scheduled

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@869 48356398-32a2-884e-a903-53898d9a118a
2007-03-24 01:04:06 +00:00
Edward Z. Yang
cec7a1c087 Release 1.4.1, merged in 685-687.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@689 48356398-32a2-884e-a903-53898d9a118a
2007-01-21 21:54:03 +00:00
Edward Z. Yang
c2d3d5b859 Release 1.4.0.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@682 48356398-32a2-884e-a903-53898d9a118a
2007-01-21 17:45:33 +00:00
Edward Z. Yang
9a84e11f34 Merge in r657-674, prompted by near release of 1.4.0.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@675 48356398-32a2-884e-a903-53898d9a118a
2007-01-21 16:07:36 +00:00
Edward Z. Yang
37ea1673dd Merge in r649-656, prompted by changing two of Encoder's functions to static.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@657 48356398-32a2-884e-a903-53898d9a118a
2007-01-19 02:28:53 +00:00
Edward Z. Yang
5395d8b4bd Renamed remotely
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@649 48356398-32a2-884e-a903-53898d9a118a
2007-01-16 22:03:54 +00:00
Edward Z. Yang
c980e76197 Moved remotely
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/trunk-strict@648 48356398-32a2-884e-a903-53898d9a118a
2007-01-16 22:03:00 +00:00
Edward Z. Yang
2bf912d528 Commit strict version of HTML Purifier.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk-strict@647 48356398-32a2-884e-a903-53898d9a118a
2007-01-16 21:59:29 +00:00
22 changed files with 51 additions and 58 deletions

4
NEWS
View File

@@ -298,6 +298,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
%Attr.IDBlacklistRegexp %Attr.IDBlacklistRegexp
- Error messages are emitted when you attempt to "allow" elements or - Error messages are emitted when you attempt to "allow" elements or
attributes that HTML Purifier does not support attributes that HTML Purifier does not support
- Fix segfault in unit test. The problem is not very reproduceable and - Fix segfault in unit test. The problem is not very reproduceable and
I don't know what causes it, but a six line patch fixed it. I don't know what causes it, but a six line patch fixed it.
@@ -496,4 +498,4 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
! First public release, most functionality implemented. Notable omissions are: ! First public release, most functionality implemented. Notable omissions are:
+ Shorthand CSS properties + Shorthand CSS properties
+ Table CSS properties + Table CSS properties
+ Deprecated attribute transformations + Deprecated attribute transformations

1
TODO
View File

@@ -1,4 +1,3 @@
TODO List TODO List
= KEY ==================== = KEY ====================

View File

@@ -213,10 +213,10 @@ class HTMLPurifier
* @param $prototype Optional prototype HTMLPurifier instance to * @param $prototype Optional prototype HTMLPurifier instance to
* overload singleton with. * overload singleton with.
*/ */
function &getInstance($prototype = null) { static function &getInstance($prototype = null) {
static $htmlpurifier; static $htmlpurifier;
if (!$htmlpurifier || $prototype) { if (!$htmlpurifier || $prototype) {
if (is_a($prototype, 'HTMLPurifier')) { if ($prototype instanceof HTMLPurifier) {
$htmlpurifier = $prototype; $htmlpurifier = $prototype;
} elseif ($prototype) { } elseif ($prototype) {
$htmlpurifier = new HTMLPurifier($prototype); $htmlpurifier = new HTMLPurifier($prototype);

View File

@@ -99,11 +99,8 @@ class HTMLPurifier_Config
* or a string filename of an ini file. * or a string filename of an ini file.
* @return Configured HTMLPurifier_Config object * @return Configured HTMLPurifier_Config object
*/ */
function create($config) { static function create($config) {
if (is_a($config, 'HTMLPurifier_Config')) { if ($config instanceof HTMLPurifier_Config) return $config;
// pass-through
return $config;
}
$ret = HTMLPurifier_Config::createDefault(); $ret = HTMLPurifier_Config::createDefault();
if (is_string($config)) $ret->loadIni($config); if (is_string($config)) $ret->loadIni($config);
elseif (is_array($config)) $ret->loadArray($config); elseif (is_array($config)) $ret->loadArray($config);
@@ -115,7 +112,7 @@ class HTMLPurifier_Config
* @static * @static
* @return Default HTMLPurifier_Config object. * @return Default HTMLPurifier_Config object.
*/ */
function createDefault() { static function createDefault() {
$definition =& HTMLPurifier_ConfigSchema::instance(); $definition =& HTMLPurifier_ConfigSchema::instance();
$config = new HTMLPurifier_Config($definition); $config = new HTMLPurifier_Config($definition);
return $config; return $config;
@@ -368,7 +365,7 @@ class HTMLPurifier_Config
* @param $allowed List of allowed namespaces/directives * @param $allowed List of allowed namespaces/directives
* @static * @static
*/ */
function getAllowedDirectivesForForm($allowed) { static function getAllowedDirectivesForForm($allowed) {
$schema = HTMLPurifier_ConfigSchema::instance(); $schema = HTMLPurifier_ConfigSchema::instance();
if ($allowed !== true) { if ($allowed !== true) {
if (is_string($allowed)) $allowed = array($allowed); if (is_string($allowed)) $allowed = array($allowed);
@@ -413,7 +410,7 @@ class HTMLPurifier_Config
* @param $mq_fix Boolean whether or not to enable magic quotes fix * @param $mq_fix Boolean whether or not to enable magic quotes fix
* @static * @static
*/ */
function loadArrayFromForm($array, $index, $allowed = true, $mq_fix = true) { static function loadArrayFromForm($array, $index, $allowed = true, $mq_fix = true) {
$ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix); $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix);
$config = HTMLPurifier_Config::create($ret); $config = HTMLPurifier_Config::create($ret);
return $config; return $config;
@@ -433,7 +430,7 @@ class HTMLPurifier_Config
* strict parts of HTMLPurifier_Config * strict parts of HTMLPurifier_Config
* @static * @static
*/ */
function prepareArrayFromForm($array, $index, $allowed = true, $mq_fix = true) { static function prepareArrayFromForm($array, $index, $allowed = true, $mq_fix = true) {
$array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
$mq = get_magic_quotes_gpc() && $mq_fix; $mq = get_magic_quotes_gpc() && $mq_fix;

View File

@@ -82,7 +82,7 @@ class HTMLPurifier_ConfigSchema {
* Retrieves an instance of the application-wide configuration definition. * Retrieves an instance of the application-wide configuration definition.
* @static * @static
*/ */
function &instance($prototype = null) { static function &instance($prototype = null) {
static $instance; static $instance;
if ($prototype !== null) { if ($prototype !== null) {
$instance = $prototype; $instance = $prototype;
@@ -104,7 +104,7 @@ class HTMLPurifier_ConfigSchema {
* HTMLPurifier_DirectiveDef::$type for allowed values * HTMLPurifier_DirectiveDef::$type for allowed values
* @param $description Description of directive for documentation * @param $description Description of directive for documentation
*/ */
function define($namespace, $name, $default, $type, $description) { static function define($namespace, $name, $default, $type, $description) {
$def =& HTMLPurifier_ConfigSchema::instance(); $def =& HTMLPurifier_ConfigSchema::instance();
// basic sanity checks // basic sanity checks
@@ -177,7 +177,7 @@ class HTMLPurifier_ConfigSchema {
* @param $namespace Namespace's name * @param $namespace Namespace's name
* @param $description Description of the namespace * @param $description Description of the namespace
*/ */
function defineNamespace($namespace, $description) { static function defineNamespace($namespace, $description) {
$def =& HTMLPurifier_ConfigSchema::instance(); $def =& HTMLPurifier_ConfigSchema::instance();
if (HTMLPURIFIER_SCHEMA_STRICT) { if (HTMLPURIFIER_SCHEMA_STRICT) {
if (isset($def->info[$namespace])) { if (isset($def->info[$namespace])) {
@@ -212,7 +212,7 @@ class HTMLPurifier_ConfigSchema {
* @param $alias Name of aliased value * @param $alias Name of aliased value
* @param $real Value aliased value will be converted into * @param $real Value aliased value will be converted into
*/ */
function defineValueAliases($namespace, $name, $aliases) { static function defineValueAliases($namespace, $name, $aliases) {
$def =& HTMLPurifier_ConfigSchema::instance(); $def =& HTMLPurifier_ConfigSchema::instance();
if (HTMLPURIFIER_SCHEMA_STRICT && !isset($def->info[$namespace][$name])) { if (HTMLPURIFIER_SCHEMA_STRICT && !isset($def->info[$namespace][$name])) {
trigger_error('Cannot set value alias for non-existant directive', trigger_error('Cannot set value alias for non-existant directive',
@@ -245,7 +245,7 @@ class HTMLPurifier_ConfigSchema {
* @param $name Name of directive * @param $name Name of directive
* @param $allowed_values Arraylist of allowed values * @param $allowed_values Arraylist of allowed values
*/ */
function defineAllowedValues($namespace, $name, $allowed_values) { static function defineAllowedValues($namespace, $name, $allowed_values) {
$def =& HTMLPurifier_ConfigSchema::instance(); $def =& HTMLPurifier_ConfigSchema::instance();
if (HTMLPURIFIER_SCHEMA_STRICT && !isset($def->info[$namespace][$name])) { if (HTMLPURIFIER_SCHEMA_STRICT && !isset($def->info[$namespace][$name])) {
trigger_error('Cannot define allowed values for undefined directive', trigger_error('Cannot define allowed values for undefined directive',
@@ -285,7 +285,7 @@ class HTMLPurifier_ConfigSchema {
* @param $new_namespace * @param $new_namespace
* @param $new_name Directive that the alias will be to * @param $new_name Directive that the alias will be to
*/ */
function defineAlias($namespace, $name, $new_namespace, $new_name) { static function defineAlias($namespace, $name, $new_namespace, $new_name) {
$def =& HTMLPurifier_ConfigSchema::instance(); $def =& HTMLPurifier_ConfigSchema::instance();
if (HTMLPURIFIER_SCHEMA_STRICT) { if (HTMLPURIFIER_SCHEMA_STRICT) {
if (!isset($def->info[$namespace])) { if (!isset($def->info[$namespace])) {
@@ -428,7 +428,7 @@ class HTMLPurifier_ConfigSchema {
*/ */
function isError($var) { function isError($var) {
if (!is_object($var)) return false; if (!is_object($var)) return false;
if (!is_a($var, 'HTMLPurifier_Error')) return false; if (!($var instanceof HTMLPurifier_Error)) return false;
return true; return true;
} }
} }

View File

@@ -40,7 +40,7 @@ class HTMLPurifier_DefinitionCacheFactory
* Retrieves an instance of global definition cache factory. * Retrieves an instance of global definition cache factory.
* @static * @static
*/ */
function &instance($prototype = null) { static function &instance($prototype = null) {
static $instance; static $instance;
if ($prototype !== null) { if ($prototype !== null) {
$instance = $prototype; $instance = $prototype;

View File

@@ -110,7 +110,7 @@ class HTMLPurifier_ElementDef
* Low-level factory constructor for creating new standalone element defs * Low-level factory constructor for creating new standalone element defs
* @static * @static
*/ */
function create($safe, $content_model, $content_model_type, $attr) { static function create($safe, $content_model, $content_model_type, $attr) {
$def = new HTMLPurifier_ElementDef(); $def = new HTMLPurifier_ElementDef();
$def->safe = (bool) $safe; $def->safe = (bool) $safe;
$def->content_model = $content_model; $def->content_model = $content_model;

View File

@@ -88,7 +88,7 @@ class HTMLPurifier_Encoder
* would need that, and I'm probably not going to implement them. * would need that, and I'm probably not going to implement them.
* Once again, PHP 6 should solve all our problems. * Once again, PHP 6 should solve all our problems.
*/ */
function cleanUTF8($str, $force_php = false) { static function cleanUTF8($str, $force_php = false) {
static $non_sgml_chars = array(); static $non_sgml_chars = array();
if (empty($non_sgml_chars)) { if (empty($non_sgml_chars)) {
@@ -271,7 +271,7 @@ class HTMLPurifier_Encoder
// | 00000000 | 00010000 | 11111111 | 11111111 | Defined upper limit of legal scalar codes // | 00000000 | 00010000 | 11111111 | 11111111 | Defined upper limit of legal scalar codes
// +----------+----------+----------+----------+ // +----------+----------+----------+----------+
function unichr($code) { static function unichr($code) {
if($code > 1114111 or $code < 0 or if($code > 1114111 or $code < 0 or
($code >= 55296 and $code <= 57343) ) { ($code >= 55296 and $code <= 57343) ) {
// bits are set outside the "valid" range as defined // bits are set outside the "valid" range as defined
@@ -312,7 +312,7 @@ class HTMLPurifier_Encoder
* Converts a string to UTF-8 based on configuration. * Converts a string to UTF-8 based on configuration.
* @static * @static
*/ */
function convertToUTF8($str, $config, &$context) { static function convertToUTF8($str, $config, &$context) {
static $iconv = null; static $iconv = null;
if ($iconv === null) $iconv = function_exists('iconv'); if ($iconv === null) $iconv = function_exists('iconv');
$encoding = $config->get('Core', 'Encoding'); $encoding = $config->get('Core', 'Encoding');
@@ -331,7 +331,7 @@ class HTMLPurifier_Encoder
* @note Currently, this is a lossy conversion, with unexpressable * @note Currently, this is a lossy conversion, with unexpressable
* characters being omitted. * characters being omitted.
*/ */
function convertFromUTF8($str, $config, &$context) { static function convertFromUTF8($str, $config, &$context) {
static $iconv = null; static $iconv = null;
if ($iconv === null) $iconv = function_exists('iconv'); if ($iconv === null) $iconv = function_exists('iconv');
$encoding = $config->get('Core', 'Encoding'); $encoding = $config->get('Core', 'Encoding');
@@ -364,7 +364,7 @@ class HTMLPurifier_Encoder
* @note Sort of with cleanUTF8() but it assumes that $str is * @note Sort of with cleanUTF8() but it assumes that $str is
* well-formed UTF-8 * well-formed UTF-8
*/ */
function convertToASCIIDumbLossless($str) { static function convertToASCIIDumbLossless($str) {
$bytesleft = 0; $bytesleft = 0;
$result = ''; $result = '';
$working = 0; $working = 0;

View File

@@ -29,7 +29,7 @@ class HTMLPurifier_EntityLookup {
* @static * @static
* @param Optional prototype of custom lookup table to overload with. * @param Optional prototype of custom lookup table to overload with.
*/ */
function instance($prototype = false) { static function instance($prototype = false) {
// no references, since PHP doesn't copy unless modified // no references, since PHP doesn't copy unless modified
static $instance = null; static $instance = null;
if ($prototype) { if ($prototype) {

View File

@@ -27,7 +27,7 @@ class HTMLPurifier_IDAccumulator
* @return Fully initialized HTMLPurifier_IDAccumulator * @return Fully initialized HTMLPurifier_IDAccumulator
* @static * @static
*/ */
function build($config, &$context) { static function build($config, &$context) {
$id_accumulator = new HTMLPurifier_IDAccumulator(); $id_accumulator = new HTMLPurifier_IDAccumulator();
$id_accumulator->load($config->get('Attr', 'IDBlacklist')); $id_accumulator->load($config->get('Attr', 'IDBlacklist'));
return $id_accumulator; return $id_accumulator;

View File

@@ -113,7 +113,7 @@ class HTMLPurifier_Language
$generator = false; $generator = false;
foreach ($args as $i => $value) { foreach ($args as $i => $value) {
if (is_object($value)) { if (is_object($value)) {
if (is_a($value, 'HTMLPurifier_Token')) { if ($value instanceof HTMLPurifier_Token) {
// factor this out some time // factor this out some time
if (!$generator) $generator = $this->context->get('Generator'); if (!$generator) $generator = $this->context->get('Generator');
if (isset($value->name)) $subst['$'.$i.'.Name'] = $value->name; if (isset($value->name)) $subst['$'.$i.'.Name'] = $value->name;

View File

@@ -65,7 +65,7 @@ class HTMLPurifier_LanguageFactory
* @param $prototype Optional prototype to overload sole instance with, * @param $prototype Optional prototype to overload sole instance with,
* or bool true to reset to default factory. * or bool true to reset to default factory.
*/ */
function &instance($prototype = null) { static function &instance($prototype = null) {
static $instance = null; static $instance = null;
if ($prototype !== null) { if ($prototype !== null) {
$instance = $prototype; $instance = $prototype;

View File

@@ -148,9 +148,9 @@ class HTMLPurifier_Lexer
* @param $prototype Optional prototype lexer or configuration object * @param $prototype Optional prototype lexer or configuration object
* @return Concrete lexer. * @return Concrete lexer.
*/ */
function create($config) { static function create($config) {
if (!is_a($config, 'HTMLPurifier_Config')) { if (!($config instanceof HTMLPurifier_Config)) {
$lexer = $config; $lexer = $config;
trigger_error("Passing a prototype to trigger_error("Passing a prototype to
HTMLPurifier_Lexer::create() is deprecated, please instead HTMLPurifier_Lexer::create() is deprecated, please instead
@@ -278,7 +278,7 @@ class HTMLPurifier_Lexer
* @param $string HTML string to process. * @param $string HTML string to process.
* @returns HTML with CDATA sections escaped. * @returns HTML with CDATA sections escaped.
*/ */
function escapeCDATA($string) { static function escapeCDATA($string) {
return preg_replace_callback( return preg_replace_callback(
'/<!\[CDATA\[(.+?)\]\]>/s', '/<!\[CDATA\[(.+?)\]\]>/s',
array('HTMLPurifier_Lexer', 'CDATACallback'), array('HTMLPurifier_Lexer', 'CDATACallback'),
@@ -307,7 +307,7 @@ class HTMLPurifier_Lexer
* and 1 the inside of the CDATA section. * and 1 the inside of the CDATA section.
* @returns Escaped internals of the CDATA section. * @returns Escaped internals of the CDATA section.
*/ */
function CDATACallback($matches) { static function CDATACallback($matches) {
// not exactly sure why the character set is needed, but whatever // not exactly sure why the character set is needed, but whatever
return htmlspecialchars($matches[1], ENT_COMPAT, 'UTF-8'); return htmlspecialchars($matches[1], ENT_COMPAT, 'UTF-8');
} }

View File

@@ -158,7 +158,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
* Callback function for undoing escaping of stray angled brackets * Callback function for undoing escaping of stray angled brackets
* in comments * in comments
*/ */
function callbackUndoCommentSubst($matches) { static public function callbackUndoCommentSubst($matches) {
return '<!--' . strtr($matches[1], array('&amp;'=>'&','&lt;'=>'<')) . $matches[2]; return '<!--' . strtr($matches[1], array('&amp;'=>'&','&lt;'=>'<')) . $matches[2];
} }
@@ -166,7 +166,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
* Callback function that entity-izes ampersands in comments so that * Callback function that entity-izes ampersands in comments so that
* callbackUndoCommentSubst doesn't clobber them * callbackUndoCommentSubst doesn't clobber them
*/ */
function callbackArmorCommentEntities($matches) { static public function callbackArmorCommentEntities($matches) {
return '<!--' . str_replace('&', '&amp;', $matches[1]) . $matches[2]; return '<!--' . str_replace('&', '&amp;', $matches[1]) . $matches[2];
} }

View File

@@ -40,7 +40,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
* @param $matches, in form of array(opening tag, contents, closing tag) * @param $matches, in form of array(opening tag, contents, closing tag)
* @static * @static
*/ */
function scriptCallback($matches) { static function scriptCallback($matches) {
return $matches[1] . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8') . $matches[3]; return $matches[1] . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8') . $matches[3];
} }

View File

@@ -44,7 +44,7 @@ class HTMLPurifier_URISchemeRegistry
* @note Pass a registry object $prototype with a compatible interface and * @note Pass a registry object $prototype with a compatible interface and
* the function will copy it and return it all further times. * the function will copy it and return it all further times.
*/ */
function &instance($prototype = null) { static function &instance($prototype = null) {
static $instance = null; static $instance = null;
if ($prototype !== null) { if ($prototype !== null) {
$instance = $prototype; $instance = $prototype;

View File

@@ -7,7 +7,7 @@ if (!isset($_GET['standalone'])) {
} else { } else {
require_once '../library/HTMLPurifier.standalone.php'; require_once '../library/HTMLPurifier.standalone.php';
} }
error_reporting(E_ALL); error_reporting(E_ALL | E_STRICT);
function escapeHTML($string) { function escapeHTML($string) {
$string = HTMLPurifier_Encoder::cleanUTF8($string); $string = HTMLPurifier_Encoder::cleanUTF8($string);

View File

@@ -86,7 +86,7 @@ class Debugger
/** /**
* @static * @static
*/ */
function &instance() { static function &instance() {
static $soleInstance = false; static $soleInstance = false;
if (!$soleInstance) $soleInstance = new Debugger(); if (!$soleInstance) $soleInstance = new Debugger();
return $soleInstance; return $soleInstance;

View File

@@ -2,11 +2,12 @@
require_once 'HTMLPurifier/AttrCollections.php'; require_once 'HTMLPurifier/AttrCollections.php';
Mock::generatePartial( class HTMLPurifier_AttrCollectionsTest_NoConstructor extends HTMLPurifier_AttrCollections
'HTMLPurifier_AttrCollections', {
'HTMLPurifier_AttrCollections_TestForConstruct', function HTMLPurifier_AttrCollectionsTest_NoConstructor() {}
array('performInclusions', 'expandIdentifiers') function expandIdentifiers(&$a, $b) {}
); function performInclusions(&$a) {}
}
class HTMLPurifier_AttrCollectionsTest extends HTMLPurifier_Harness class HTMLPurifier_AttrCollectionsTest extends HTMLPurifier_Harness
{ {
@@ -15,7 +16,7 @@ class HTMLPurifier_AttrCollectionsTest extends HTMLPurifier_Harness
generate_mock_once('HTMLPurifier_AttrTypes'); generate_mock_once('HTMLPurifier_AttrTypes');
$collections = new HTMLPurifier_AttrCollections_TestForConstruct(); $collections = new HTMLPurifier_AttrCollectionsTest_NoConstructor();
$types = new HTMLPurifier_AttrTypesMock(); $types = new HTMLPurifier_AttrTypesMock();

View File

@@ -25,7 +25,7 @@ class HTMLPurifier_ErrorCollectorEMock extends HTMLPurifier_ErrorCollectorMock
$this->_expected_context_at[$step][$key] = $value; $this->_expected_context_at[$step][$key] = $value;
} }
function send() { function send($severity, $msg) {
// test for context // test for context
$context =& SimpleTest::getContext(); $context =& SimpleTest::getContext();
$test =& $context->getTest(); $test =& $context->getTest();

View File

@@ -3,7 +3,9 @@
// call one file using /?f=FileTest.php , see $test_files array for // call one file using /?f=FileTest.php , see $test_files array for
// valid values // valid values
error_reporting(E_ALL); if (version_compare(PHP_VERSION, '5.1', '>=')) error_reporting(E_ALL | E_STRICT);
else error_reporting(E_ALL);
define('HTMLPurifierTest', 1); define('HTMLPurifierTest', 1);
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
@@ -80,7 +82,7 @@ if ($test_file = $GLOBALS['HTMLPurifierTest']['File']) {
} else { } else {
$test = new GroupTest('All HTML Purifier tests on PHP ' . PHP_VERSION); $test = new GroupTest('All tests on PHP ' . PHP_VERSION);
foreach ($test_files as $test_file) { foreach ($test_files as $test_file) {
require_once $test_file; require_once $test_file;
$test->addTestClass(path2class($test_file)); $test->addTestClass(path2class($test_file));

View File

@@ -2,14 +2,6 @@
$versions_to_test = array( $versions_to_test = array(
'FLUSH', 'FLUSH',
'4.3.7',
'4.3.8',
'4.3.9',
'FLUSH', // serialize's behavior changed to be non-backwards-compat
'4.3.10',
'4.3.11',
'4.4.6',
'4.4.7',
'5.0.4', '5.0.4',
'5.0.5', '5.0.5',
'5.1.4', '5.1.4',