1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 05:37:49 +02:00

Compare commits

..

10 Commits

Author SHA1 Message Date
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
13 changed files with 310 additions and 319 deletions

View File

@@ -53,8 +53,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')) return $config; if ($config instanceof HTMLPurifier_Config) 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);
@@ -66,7 +66,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;

View File

@@ -73,7 +73,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;
@@ -95,7 +95,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( static function define(
$namespace, $name, $default, $type, $namespace, $name, $default, $type,
$description $description
) { ) {
@@ -159,7 +159,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 (isset($def->info[$namespace])) { if (isset($def->info[$namespace])) {
trigger_error('Cannot redefine namespace', E_USER_ERROR); trigger_error('Cannot redefine namespace', E_USER_ERROR);
@@ -192,7 +192,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 (!isset($def->info[$namespace][$name])) { if (!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',
@@ -223,7 +223,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 (!isset($def->info[$namespace][$name])) { if (!isset($def->info[$namespace][$name])) {
trigger_error('Cannot define allowed values for undefined directive', trigger_error('Cannot define allowed values for undefined directive',
@@ -260,7 +260,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 (!isset($def->info[$namespace])) { if (!isset($def->info[$namespace])) {
trigger_error('Cannot define directive alias in undefined namespace', trigger_error('Cannot define directive alias in undefined namespace',
@@ -378,7 +378,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

@@ -90,7 +90,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)) {
@@ -273,7 +273,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
@@ -314,7 +314,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');
@@ -333,7 +333,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');
@@ -366,7 +366,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

@@ -57,7 +57,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

@@ -144,7 +144,7 @@ class HTMLPurifier_Lexer
* @param $prototype Optional prototype lexer. * @param $prototype Optional prototype lexer.
* @return Concrete lexer. * @return Concrete lexer.
*/ */
function create($prototype = null) { static function create($prototype = null) {
// we don't really care if it's a reference or a copy // we don't really care if it's a reference or a copy
static $lexer = null; static $lexer = null;
if ($prototype) { if ($prototype) {
@@ -171,7 +171,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\[(.+?)\]\]>/', '/<!\[CDATA\[(.+?)\]\]>/',
array('HTMLPurifier_Lexer', 'CDATACallback'), array('HTMLPurifier_Lexer', 'CDATACallback'),
@@ -189,7 +189,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

@@ -38,7 +38,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

@@ -3,7 +3,7 @@
header('Content-type: text/html; charset=UTF-8'); header('Content-type: text/html; charset=UTF-8');
require_once '../library/HTMLPurifier.auto.php'; require_once '../library/HTMLPurifier.auto.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

@@ -73,7 +73,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

@@ -187,11 +187,9 @@ class HTMLPurifier_HTMLModuleManagerTest extends UnitTestCase
$this->expectError( // active variables, watch out! $this->expectError( // active variables, watch out!
'Illegal inclusion array at index 1 found collection HTML, '. 'Illegal inclusion array at index 1 found collection HTML, '.
'inclusion arrays must be at start of collection (index 0)'); 'inclusion arrays must be at start of collection (index 0)');
$c = array( $c = array(
'HTML' => array('Legacy', array('XHTML')), 'HTML' => array('Legacy', array('XHTML')),
'XHTML' => array('Text', 'Hypertext') 'XHTML' => array('Text', 'Hypertext')
); );
$this->manager->processCollections($c); $this->manager->processCollections($c);
unset($c); unset($c);
@@ -200,8 +198,6 @@ class HTMLPurifier_HTMLModuleManagerTest extends UnitTestCase
'module Foobar'); 'module Foobar');
$c = array( $c = array(
'HTML' => array('Foobar') 'HTML' => array('Foobar')
); );
$this->manager->processCollections($c); $this->manager->processCollections($c);
unset($c); unset($c);
@@ -210,8 +206,6 @@ class HTMLPurifier_HTMLModuleManagerTest extends UnitTestCase
'collection _Common'); 'collection _Common');
$c = array( $c = array(
'HTML' => array(array('_Common'), 'Legacy') 'HTML' => array(array('_Common'), 'Legacy')
); );
$this->manager->processCollections($c); $this->manager->processCollections($c);
unset($c); unset($c);
@@ -221,8 +215,6 @@ class HTMLPurifier_HTMLModuleManagerTest extends UnitTestCase
$c = array( $c = array(
'HTML' => array(array('XHTML')), 'HTML' => array(array('XHTML')),
'XHTML' => array(array('HTML')) 'XHTML' => array(array('HTML'))
); );
$this->manager->processCollections($c); $this->manager->processCollections($c);
unset($c); unset($c);

View File

@@ -16,9 +16,8 @@ class HTMLPurifier_LexerTest extends UnitTestCase
$this->DirectLex = new HTMLPurifier_Lexer_DirectLex(); $this->DirectLex = new HTMLPurifier_Lexer_DirectLex();
// E_STRICT = 2048, int used for PHP4 compat
if ( $GLOBALS['HTMLPurifierTest']['PEAR'] && if ( $GLOBALS['HTMLPurifierTest']['PEAR'] &&
((error_reporting() & 2048) != 2048) ((error_reporting() & E_STRICT) != E_STRICT)
) { ) {
$this->_has_pear = true; $this->_has_pear = true;
require_once 'HTMLPurifier/Lexer/PEARSax3.php'; require_once 'HTMLPurifier/Lexer/PEARSax3.php';

View File

@@ -3,7 +3,7 @@
// 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); error_reporting(E_ALL | E_STRICT);
define('HTMLPurifierTest', 1); define('HTMLPurifierTest', 1);
// wishlist: automated calling of this file from multiple PHP versions so we // wishlist: automated calling of this file from multiple PHP versions so we