0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-23 00:41:52 +00:00

[3.0.0] Convert all $context calls away from references

- Update TODO list
- URISchemeRegistry doesn't return a reference for instance anymore, should do the same for other singletons

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1477 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2008-01-05 00:10:43 +00:00
parent beefb11879
commit a7fab00cdd
101 changed files with 131 additions and 120 deletions

3
NEWS
View File

@ -15,7 +15,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
to it. to it.
+ Visibility declarations added + Visibility declarations added
+ Constructor methods renamed to __construct() + Constructor methods renamed to __construct()
+ PHP4 reference/foreach cruft removed (in progress) + PHP4 reference cruft removed (in progress)
! CSS properties are no case-insensitive ! CSS properties are no case-insensitive
! DefinitionCacheFactory now can register new implementations ! DefinitionCacheFactory now can register new implementations
! New HTMLPurifier_Filter_ExtractStyleBlocks for extracting <style> from ! New HTMLPurifier_Filter_ExtractStyleBlocks for extracting <style> from
@ -31,6 +31,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
. New classes: . New classes:
+ HTMLPurifier_AttrDef_CSS_AlphaValue + HTMLPurifier_AttrDef_CSS_AlphaValue
+ HTMLPurifier_AttrDef_CSS_Filter + HTMLPurifier_AttrDef_CSS_Filter
. Multitest now has a file docblock
2.1.3, released 2007-11-05 2.1.3, released 2007-11-05
! tests/multitest.php allows you to test multiple versions by running ! tests/multitest.php allows you to test multiple versions by running

5
TODO
View File

@ -12,7 +12,6 @@ amount of effort to implement, it may get endlessly delayed. Do not be
afraid to cast your vote for the next feature to be implemented! afraid to cast your vote for the next feature to be implemented!
3.0 release [Go PHP5!] 3.0 release [Go PHP5!]
- Convert all &$context calls to $context, as PHP5 passes objects by value
- Allow extracted CSS blocks to have a bounding selector prepended to all - Allow extracted CSS blocks to have a bounding selector prepended to all
of their declarations. There are two types: a global type and a HTML5 of their declarations. There are two types: a global type and a HTML5
scoped type. This will allow for <style> while minimizing the risk of scoped type. This will allow for <style> while minimizing the risk of
@ -61,10 +60,10 @@ afraid to cast your vote for the next feature to be implemented!
- Lots of documentation and samples - Lots of documentation and samples
Ongoing Ongoing
- More refactoring to take advantage of PHP5's facilities
- Lots of profiling, make it faster! - Lots of profiling, make it faster!
- Plugins for major CMSes (COMPLEX) - Plugins for major CMSes (COMPLEX)
- phpBB - phpBB
- eFiction
- more! (look for ones that use WYSIWYGs) - more! (look for ones that use WYSIWYGs)
- Complete basic smoketests - Complete basic smoketests
@ -75,6 +74,8 @@ AutoFormat
Unknown release (on a scratch-an-itch basis) Unknown release (on a scratch-an-itch basis)
# CHMOD install script for PEAR installs # CHMOD install script for PEAR installs
# Convert multitest to use the XML format
# Make test/index.php have better cli flags
? Have 'lang' attribute be checked against official lists, achieved by ? Have 'lang' attribute be checked against official lists, achieved by
encoding all characters that have string entity equivalents encoding all characters that have string entity equivalents
- Abstract ChildDef_BlockQuote to work with all elements that only - Abstract ChildDef_BlockQuote to work with all elements that only

View File

@ -32,7 +32,7 @@ abstract class HTMLPurifier_AttrDef
* @param $config Mandatory HTMLPurifier_Config object. * @param $config Mandatory HTMLPurifier_Config object.
* @param $context Mandatory HTMLPurifier_AttrContext object. * @param $context Mandatory HTMLPurifier_AttrContext object.
*/ */
abstract public function validate($string, $config, &$context); abstract public function validate($string, $config, $context);
/** /**
* Convenience method that parses a string as if it were CDATA. * Convenience method that parses a string as if it were CDATA.

View File

@ -17,7 +17,7 @@ require_once 'HTMLPurifier/CSSDefinition.php';
class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef
{ {
public function validate($css, $config, &$context) { public function validate($css, $config, $context) {
$css = $this->parseCDATA($css); $css = $this->parseCDATA($css);

View File

@ -10,7 +10,7 @@ class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Numbe
parent::__construct(false); // opacity is non-negative, but we will clamp it parent::__construct(false); // opacity is non-negative, but we will clamp it
} }
public function validate($number, $config, &$context) { public function validate($number, $config, $context) {
$result = parent::validate($number, $config, $context); $result = parent::validate($number, $config, $context);
if ($result === false) return $result; if ($result === false) return $result;
$float = (float) $result; $float = (float) $result;

View File

@ -25,7 +25,7 @@ class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef
$this->info['background-position'] = $def->info['background-position']; $this->info['background-position'] = $def->info['background-position'];
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
// regular pre-processing // regular pre-processing
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);

View File

@ -56,7 +56,7 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
$this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage(); $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage();
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
$bits = explode(' ', $string); $bits = explode(' ', $string);

View File

@ -20,7 +20,7 @@ class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
$this->info['border-top-color'] = $def->info['border-top-color']; $this->info['border-top-color'] = $def->info['border-top-color'];
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
// we specifically will not support rgb() syntax with spaces // we specifically will not support rgb() syntax with spaces
$bits = explode(' ', $string); $bits = explode(' ', $string);

View File

@ -33,7 +33,7 @@ This directive has been available since 2.0.0.
class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
{ {
public function validate($color, $config, &$context) { public function validate($color, $config, $context) {
static $colors = null; static $colors = null;
if ($colors === null) $colors = $config->get('Core', 'ColorKeywords'); if ($colors === null) $colors = $config->get('Core', 'ColorKeywords');

View File

@ -25,7 +25,7 @@ class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef
$this->defs = $defs; $this->defs = $defs;
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
foreach ($this->defs as $i => $def) { foreach ($this->defs as $i => $def) {
$result = $this->defs[$i]->validate($string, $config, $context); $result = $this->defs[$i]->validate($string, $config, $context);
if ($result !== false) return $result; if ($result !== false) return $result;

View File

@ -17,7 +17,7 @@ class HTMLPurifier_AttrDef_CSS_Filter extends HTMLPurifier_AttrDef
$this->intValidator = new HTMLPurifier_AttrDef_Integer(); $this->intValidator = new HTMLPurifier_AttrDef_Integer();
} }
public function validate($value, $config, &$context) { public function validate($value, $config, $context) {
$value = $this->parseCDATA($value); $value = $this->parseCDATA($value);
if ($value === 'none') return $value; if ($value === 'none') return $value;
// if we looped this we could support multiple filters // if we looped this we could support multiple filters

View File

@ -28,7 +28,7 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef
$this->info['font-family'] = $def->info['font-family']; $this->info['font-family'] = $def->info['font-family'];
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
static $system_fonts = array( static $system_fonts = array(
'caption' => true, 'caption' => true,

View File

@ -10,7 +10,7 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
static $generic_names = array( static $generic_names = array(
'serif' => true, 'serif' => true,
'sans-serif' => true, 'sans-serif' => true,

View File

@ -29,7 +29,7 @@ class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef
$this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative);
} }
public function validate($length, $config, &$context) { public function validate($length, $config, $context) {
$length = $this->parseCDATA($length); $length = $this->parseCDATA($length);
if ($length === '') return false; if ($length === '') return false;

View File

@ -22,7 +22,7 @@ class HTMLPurifier_AttrDef_CSS_ListStyle extends HTMLPurifier_AttrDef
$this->info['list-style-image'] = $def->info['list-style-image']; $this->info['list-style-image'] = $def->info['list-style-image'];
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
// regular pre-processing // regular pre-processing
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);

View File

@ -37,7 +37,7 @@ class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef
$this->max = $max; $this->max = $max;
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
if ($string === '') return false; if ($string === '') return false;
$parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n

View File

@ -18,7 +18,7 @@ class HTMLPurifier_AttrDef_CSS_Number extends HTMLPurifier_AttrDef
$this->non_negative = $non_negative; $this->non_negative = $non_negative;
} }
public function validate($number, $config, &$context) { public function validate($number, $config, $context) {
$number = $this->parseCDATA($number); $number = $this->parseCDATA($number);

View File

@ -21,7 +21,7 @@ class HTMLPurifier_AttrDef_CSS_Percentage extends HTMLPurifier_AttrDef
$this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative);
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);

View File

@ -10,7 +10,7 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
static $allowed_values = array( static $allowed_values = array(
'line-through' => true, 'line-through' => true,

View File

@ -18,7 +18,7 @@ class HTMLPurifier_AttrDef_CSS_URI extends HTMLPurifier_AttrDef_URI
parent::__construct(true); // always embedded parent::__construct(true); // always embedded
} }
public function validate($uri_string, $config, &$context) { public function validate($uri_string, $config, $context) {
// parse the URI out of the string and then pass it onto // parse the URI out of the string and then pass it onto
// the parent object // the parent object

View File

@ -35,7 +35,7 @@ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef
$this->case_sensitive = $case_sensitive; $this->case_sensitive = $case_sensitive;
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = trim($string); $string = trim($string);
if (!$this->case_sensitive) { if (!$this->case_sensitive) {
// we may want to do full case-insensitive libraries // we may want to do full case-insensitive libraries

View File

@ -13,7 +13,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
public function __construct($name = false) {$this->name = $name;} public function __construct($name = false) {$this->name = $name;}
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
if (empty($string)) return false; if (empty($string)) return false;
return $this->name; return $this->name;
} }

View File

@ -9,7 +9,7 @@ require_once 'HTMLPurifier/AttrDef/CSS/Color.php'; // for %Core.ColorKeywords
class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
static $colors = null; static $colors = null;
if ($colors === null) $colors = $config->get('Core', 'ColorKeywords'); if ($colors === null) $colors = $config->get('Core', 'ColorKeywords');

View File

@ -24,7 +24,7 @@ class HTMLPurifier_AttrDef_HTML_FrameTarget extends HTMLPurifier_AttrDef_Enum
public function __construct() {} public function __construct() {}
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
if ($this->valid_values === false) $this->valid_values = $config->get('Attr', 'AllowedFrameTargets'); if ($this->valid_values === false) $this->valid_values = $config->get('Attr', 'AllowedFrameTargets');
return parent::validate($string, $config, $context); return parent::validate($string, $config, $context);
} }

View File

@ -66,7 +66,7 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef
// ref functionality disabled, since we also have to verify // ref functionality disabled, since we also have to verify
// whether or not the ID it refers to exists // whether or not the ID it refers to exists
public function validate($id, $config, &$context) { public function validate($id, $config, $context) {
if (!$config->get('Attr', 'EnableID')) return false; if (!$config->get('Attr', 'EnableID')) return false;

View File

@ -13,7 +13,7 @@ require_once 'HTMLPurifier/AttrDef/HTML/Pixels.php';
class HTMLPurifier_AttrDef_HTML_Length extends HTMLPurifier_AttrDef_HTML_Pixels class HTMLPurifier_AttrDef_HTML_Length extends HTMLPurifier_AttrDef_HTML_Pixels
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = trim($string); $string = trim($string);
if ($string === '') return false; if ($string === '') return false;

View File

@ -42,7 +42,7 @@ class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
$this->name = $configLookup[$name]; $this->name = $configLookup[$name];
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$allowed = $config->get('Attr', $this->name); $allowed = $config->get('Attr', $this->name);
if (empty($allowed)) return false; if (empty($allowed)) return false;

View File

@ -12,7 +12,7 @@ require_once 'HTMLPurifier/AttrDef/HTML/Length.php';
class HTMLPurifier_AttrDef_HTML_MultiLength extends HTMLPurifier_AttrDef_HTML_Length class HTMLPurifier_AttrDef_HTML_MultiLength extends HTMLPurifier_AttrDef_HTML_Length
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = trim($string); $string = trim($string);
if ($string === '') return false; if ($string === '') return false;

View File

@ -13,7 +13,7 @@ require_once 'HTMLPurifier/Config.php';
class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = trim($string); $string = trim($string);

View File

@ -8,7 +8,7 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = trim($string); $string = trim($string);
if ($string === '0') return $string; if ($string === '0') return $string;

View File

@ -40,7 +40,7 @@ class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef
$this->positive = $positive; $this->positive = $positive;
} }
public function validate($integer, $config, &$context) { public function validate($integer, $config, $context) {
$integer = $this->parseCDATA($integer); $integer = $this->parseCDATA($integer);
if ($integer === '') return false; if ($integer === '') return false;

View File

@ -9,7 +9,7 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$string = trim($string); $string = trim($string);
if (!$string) return false; if (!$string) return false;

View File

@ -8,7 +8,7 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_Text extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_Text extends HTMLPurifier_AttrDef
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
return $this->parseCDATA($string); return $this->parseCDATA($string);
} }

View File

@ -80,7 +80,7 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
$this->embedsResource = (bool) $embeds_resource; $this->embedsResource = (bool) $embeds_resource;
} }
public function validate($uri, $config, &$context) { public function validate($uri, $config, $context) {
if ($config->get('URI', 'Disable')) return false; if ($config->get('URI', 'Disable')) return false;

View File

@ -9,7 +9,7 @@ require_once 'HTMLPurifier/AttrDef/URI/Email.php';
class HTMLPurifier_AttrDef_URI_Email_SimpleCheck extends HTMLPurifier_AttrDef_URI_Email class HTMLPurifier_AttrDef_URI_Email_SimpleCheck extends HTMLPurifier_AttrDef_URI_Email
{ {
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
// no support for named mailboxes i.e. "Bob <bob@example.com>" // no support for named mailboxes i.e. "Bob <bob@example.com>"
// that needs more percent encoding to be done // that needs more percent encoding to be done
if ($string == '') return false; if ($string == '') return false;

View File

@ -25,7 +25,7 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
$this->ipv6 = new HTMLPurifier_AttrDef_URI_IPv6(); $this->ipv6 = new HTMLPurifier_AttrDef_URI_IPv6();
} }
public function validate($string, $config, &$context) { public function validate($string, $config, $context) {
$length = strlen($string); $length = strlen($string);
if ($string === '') return ''; if ($string === '') return '';
if ($length > 1 && $string[0] === '[' && $string[$length-1] === ']') { if ($length > 1 && $string[0] === '[' && $string[$length-1] === ']') {

View File

@ -14,7 +14,7 @@ class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef
*/ */
protected $ip4; protected $ip4;
public function validate($aIP, $config, &$context) { public function validate($aIP, $config, $context) {
if (!$this->ip4) $this->_loadRegex(); if (!$this->ip4) $this->_loadRegex();

View File

@ -11,7 +11,7 @@ require_once 'HTMLPurifier/AttrDef/URI/IPv4.php';
class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4
{ {
public function validate($aIP, $config, &$context) { public function validate($aIP, $config, $context) {
if (!$this->ip4) $this->_loadRegex(); if (!$this->ip4) $this->_loadRegex();

View File

@ -26,7 +26,7 @@ abstract class HTMLPurifier_AttrTransform
* @param $context Mandatory HTMLPurifier_Context object * @param $context Mandatory HTMLPurifier_Context object
* @returns Processed attribute array. * @returns Processed attribute array.
*/ */
abstract public function transform($attr, $config, &$context); abstract public function transform($attr, $config, $context);
/** /**
* Prepends CSS properties to the style attribute, creating the * Prepends CSS properties to the style attribute, creating the

View File

@ -20,7 +20,7 @@ HTMLPurifier_ConfigSchema::defineAllowedValues(
class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform
{ {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (isset($attr['dir'])) return $attr; if (isset($attr['dir'])) return $attr;
$attr['dir'] = $config->get('Attr', 'DefaultTextDir'); $attr['dir'] = $config->get('Attr', 'DefaultTextDir');
return $attr; return $attr;

View File

@ -7,7 +7,7 @@ require_once 'HTMLPurifier/AttrTransform.php';
*/ */
class HTMLPurifier_AttrTransform_BgColor extends HTMLPurifier_AttrTransform { class HTMLPurifier_AttrTransform_BgColor extends HTMLPurifier_AttrTransform {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr['bgcolor'])) return $attr; if (!isset($attr['bgcolor'])) return $attr;

View File

@ -27,7 +27,7 @@ extends HTMLPurifier_AttrTransform {
$this->css = $css; $this->css = $css;
} }
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr[$this->attr])) return $attr; if (!isset($attr[$this->attr])) return $attr;
unset($attr[$this->attr]); unset($attr[$this->attr]);
$this->prependCSS($attr, $this->css); $this->prependCSS($attr, $this->css);

View File

@ -7,7 +7,7 @@ require_once 'HTMLPurifier/AttrTransform.php';
*/ */
class HTMLPurifier_AttrTransform_Border extends HTMLPurifier_AttrTransform { class HTMLPurifier_AttrTransform_Border extends HTMLPurifier_AttrTransform {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr['border'])) return $attr; if (!isset($attr['border'])) return $attr;
$border_width = $this->confiscateAttr($attr, 'border'); $border_width = $this->confiscateAttr($attr, 'border');
// some validation should happen here // some validation should happen here

View File

@ -36,7 +36,7 @@ class HTMLPurifier_AttrTransform_EnumToCSS extends HTMLPurifier_AttrTransform {
$this->caseSensitive = (bool) $case_sensitive; $this->caseSensitive = (bool) $case_sensitive;
} }
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr[$this->attr])) return $attr; if (!isset($attr[$this->attr])) return $attr;

View File

@ -28,7 +28,7 @@ HTMLPurifier_ConfigSchema::define(
class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
{ {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
$src = true; $src = true;
if (!isset($attr['src'])) { if (!isset($attr['src'])) {

View File

@ -20,7 +20,7 @@ class HTMLPurifier_AttrTransform_ImgSpace extends HTMLPurifier_AttrTransform {
} }
} }
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr[$this->attr])) return $attr; if (!isset($attr[$this->attr])) return $attr;

View File

@ -10,7 +10,7 @@ require_once 'HTMLPurifier/AttrTransform.php';
class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform
{ {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
$lang = isset($attr['lang']) ? $attr['lang'] : false; $lang = isset($attr['lang']) ? $attr['lang'] : false;
$xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false; $xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false;

View File

@ -16,7 +16,7 @@ class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform
$this->cssName = $css_name ? $css_name : $name; $this->cssName = $css_name ? $css_name : $name;
} }
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr[$this->name])) return $attr; if (!isset($attr[$this->name])) return $attr;
$length = $this->confiscateAttr($attr, $this->name); $length = $this->confiscateAttr($attr, $this->name);
if(ctype_digit($length)) $length .= 'px'; if(ctype_digit($length)) $length .= 'px';

View File

@ -8,7 +8,7 @@ require_once 'HTMLPurifier/AttrTransform.php';
class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform
{ {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr['name'])) return $attr; if (!isset($attr['name'])) return $attr;
$id = $this->confiscateAttr($attr, 'name'); $id = $this->confiscateAttr($attr, 'name');
if ( isset($attr['id'])) return $attr; if ( isset($attr['id'])) return $attr;

View File

@ -18,7 +18,7 @@ class HTMLPurifier_AttrValidator
* @param $config Instance of HTMLPurifier_Config * @param $config Instance of HTMLPurifier_Config
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
*/ */
public function validateToken(&$token, &$config, &$context) { public function validateToken(&$token, &$config, $context) {
$definition = $config->getHTMLDefinition(); $definition = $config->getHTMLDefinition();
$e =& $context->get('ErrorCollector', true); $e =& $context->get('ErrorCollector', true);

View File

@ -48,7 +48,7 @@ class HTMLPurifier_ChildDef
* @return bool false to remove parent node * @return bool false to remove parent node
* @return array of replacement child tokens * @return array of replacement child tokens
*/ */
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
trigger_error('Call to abstract function', E_USER_ERROR); trigger_error('Call to abstract function', E_USER_ERROR);
} }
} }

View File

@ -36,7 +36,7 @@ class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef
$this->elements = $this->block->elements; $this->elements = $this->block->elements;
} }
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
if ($context->get('IsInline') === false) { if ($context->get('IsInline') === false) {
return $this->block->validateChildren( return $this->block->validateChildren(
$tokens_of_children, $config, $context); $tokens_of_children, $config, $context);

View File

@ -61,7 +61,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
$this->_pcre_regex = $reg; $this->_pcre_regex = $reg;
} }
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
$list_of_children = ''; $list_of_children = '';
$nesting = 0; // depth into the nest $nesting = 0; // depth into the nest
foreach ($tokens_of_children as $token) { foreach ($tokens_of_children as $token) {

View File

@ -14,7 +14,7 @@ class HTMLPurifier_ChildDef_Empty extends HTMLPurifier_ChildDef
public $allow_empty = true; public $allow_empty = true;
public $type = 'empty'; public $type = 'empty';
public function __construct() {} public function __construct() {}
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
return array(); return array();
} }
} }

View File

@ -13,7 +13,7 @@ class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required
{ {
public $allow_empty = true; public $allow_empty = true;
public $type = 'optional'; public $type = 'optional';
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
$result = parent::validateChildren($tokens_of_children, $config, $context); $result = parent::validateChildren($tokens_of_children, $config, $context);
if ($result === false) { if ($result === false) {
if (empty($tokens_of_children)) return true; if (empty($tokens_of_children)) return true;

View File

@ -32,7 +32,7 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
} }
public $allow_empty = false; public $allow_empty = false;
public $type = 'required'; public $type = 'required';
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
// if there are no tokens, delete parent node // if there are no tokens, delete parent node
if (empty($tokens_of_children)) return false; if (empty($tokens_of_children)) return false;

View File

@ -13,7 +13,7 @@ extends HTMLPurifier_ChildDef_Required
public $allow_empty = true; public $allow_empty = true;
public $type = 'strictblockquote'; public $type = 'strictblockquote';
protected $init = false; protected $init = false;
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
$def = $config->getHTMLDefinition(); $def = $config->getHTMLDefinition();
if (!$this->init) { if (!$this->init) {

View File

@ -12,7 +12,7 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef
public $elements = array('tr' => true, 'tbody' => true, 'thead' => true, public $elements = array('tr' => true, 'tbody' => true, 'thead' => true,
'tfoot' => true, 'caption' => true, 'colgroup' => true, 'col' => true); 'tfoot' => true, 'caption' => true, 'colgroup' => true, 'col' => true);
public function __construct() {} public function __construct() {}
public function validateChildren($tokens_of_children, $config, &$context) { public function validateChildren($tokens_of_children, $config, $context) {
if (empty($tokens_of_children)) return false; if (empty($tokens_of_children)) return false;
// this ensures that the loop gets run one last time before closing // this ensures that the loop gets run one last time before closing

View File

@ -69,7 +69,7 @@ class HTMLPurifier_Context
* Loads a series of variables from an associative array * Loads a series of variables from an associative array
* @param $context_array Assoc array of variables to load * @param $context_array Assoc array of variables to load
*/ */
public function loadArray(&$context_array) { public function loadArray($context_array) {
foreach ($context_array as $key => $discard) { foreach ($context_array as $key => $discard) {
$this->register($key, $context_array[$key]); $this->register($key, $context_array[$key]);
} }

View File

@ -309,7 +309,7 @@ class HTMLPurifier_Encoder
/** /**
* Converts a string to UTF-8 based on configuration. * Converts a string to UTF-8 based on configuration.
*/ */
public static function convertToUTF8($str, $config, &$context) { public 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');
@ -327,7 +327,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.
*/ */
public static function convertFromUTF8($str, $config, &$context) { public 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');

View File

@ -14,7 +14,7 @@ class HTMLPurifier_ErrorCollector
protected $generator; protected $generator;
protected $context; protected $context;
public function __construct(&$context) { public function __construct($context) {
$this->locale =& $context->get('Locale'); $this->locale =& $context->get('Locale');
$this->generator =& $context->get('Generator'); $this->generator =& $context->get('Generator');
$this->context =& $context; $this->context =& $context;

View File

@ -30,14 +30,14 @@ class HTMLPurifier_Filter
/** /**
* Pre-processor function, handles HTML before HTML Purifier * Pre-processor function, handles HTML before HTML Purifier
*/ */
public function preFilter($html, $config, &$context) { public function preFilter($html, $config, $context) {
return $html; return $html;
} }
/** /**
* Post-processor function, handles HTML after HTML Purifier * Post-processor function, handles HTML after HTML Purifier
*/ */
public function postFilter($html, $config, &$context) { public function postFilter($html, $config, $context) {
return $html; return $html;
} }

View File

@ -42,7 +42,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
* Removes inline <style> tags from HTML, saves them for later use * Removes inline <style> tags from HTML, saves them for later use
* @todo Extend to indicate non-text/css style blocks * @todo Extend to indicate non-text/css style blocks
*/ */
public function preFilter($html, $config, &$context) { public function preFilter($html, $config, $context) {
$html = preg_replace_callback('#<style(?:\s.*)?>(.+)</style>#isU', array($this, 'styleCallback'), $html); $html = preg_replace_callback('#<style(?:\s.*)?>(.+)</style>#isU', array($this, 'styleCallback'), $html);
$style_blocks = $this->_styleMatches; $style_blocks = $this->_styleMatches;
$this->_styleMatches = array(); // reset $this->_styleMatches = array(); // reset
@ -63,7 +63,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
* @return Cleaned CSS * @return Cleaned CSS
*/ */
public function cleanCSS($css, $config, &$context) { public function cleanCSS($css, $config, $context) {
$this->_tidy->parse($css); $this->_tidy->parse($css);
$css_definition = $config->getDefinition('CSS'); $css_definition = $config->getDefinition('CSS');
foreach ($this->_tidy->css as &$decls) { foreach ($this->_tidy->css as &$decls) {

View File

@ -7,14 +7,14 @@ class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter
public $name = 'YouTube'; public $name = 'YouTube';
public function preFilter($html, $config, &$context) { public function preFilter($html, $config, $context) {
$pre_regex = '#<object[^>]+>.+?'. $pre_regex = '#<object[^>]+>.+?'.
'http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?</object>#s'; 'http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?</object>#s';
$pre_replace = '<span class="youtube-embed">\1</span>'; $pre_replace = '<span class="youtube-embed">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html); return preg_replace($pre_regex, $pre_replace, $html);
} }
public function postFilter($html, $config, &$context) { public function postFilter($html, $config, $context) {
$post_regex = '#<span class="youtube-embed">([A-Za-z0-9\-_]+)</span>#'; $post_regex = '#<span class="youtube-embed">([A-Za-z0-9\-_]+)</span>#';
$post_replace = '<object width="425" height="350" '. $post_replace = '<object width="425" height="350" '.
'data="http://www.youtube.com/v/\1">'. 'data="http://www.youtube.com/v/\1">'.

View File

@ -78,7 +78,7 @@ class HTMLPurifier_Generator
* @param $config HTMLPurifier_Config object * @param $config HTMLPurifier_Config object
* @return Generated HTML * @return Generated HTML
*/ */
public function generateFromTokens($tokens, $config, &$context) { public function generateFromTokens($tokens, $config, $context) {
$html = ''; $html = '';
if (!$config) $config = HTMLPurifier_Config::createDefault(); if (!$config) $config = HTMLPurifier_Config::createDefault();
$this->_scriptFix = $config->get('Output', 'CommentScriptContents'); $this->_scriptFix = $config->get('Output', 'CommentScriptContents');

View File

@ -12,7 +12,7 @@ INSIDE HTML PURIFIER DOCUMENTS. USE ONLY WITH TRUSTED USER INPUT!!!
*/ */
class HTMLPurifier_AttrTransform_ScriptRequired extends HTMLPurifier_AttrTransform class HTMLPurifier_AttrTransform_ScriptRequired extends HTMLPurifier_AttrTransform
{ {
public function transform($attr, $config, &$context) { public function transform($attr, $config, $context) {
if (!isset($attr['type'])) { if (!isset($attr['type'])) {
$attr['type'] = 'text/javascript'; $attr['type'] = 'text/javascript';
} }

View File

@ -26,7 +26,7 @@ class HTMLPurifier_IDAccumulator
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
* @return Fully initialized HTMLPurifier_IDAccumulator * @return Fully initialized HTMLPurifier_IDAccumulator
*/ */
public static function build($config, &$context) { public 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

@ -64,7 +64,7 @@ abstract class HTMLPurifier_Injector
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
* @return Boolean false if success, string of missing needed element/attribute if failure * @return Boolean false if success, string of missing needed element/attribute if failure
*/ */
public function prepare($config, &$context) { public function prepare($config, $context) {
$this->htmlDefinition = $config->getHTMLDefinition(); $this->htmlDefinition = $config->getHTMLDefinition();
// perform $needed checks // perform $needed checks
foreach ($this->needed as $element => $attributes) { foreach ($this->needed as $element => $attributes) {

View File

@ -32,7 +32,7 @@ class HTMLPurifier_Injector_PurifierLinkify extends HTMLPurifier_Injector
public $docURL; public $docURL;
public $needed = array('a' => array('href')); public $needed = array('a' => array('href'));
public function prepare($config, &$context) { public function prepare($config, $context) {
$this->docURL = $config->get('AutoFormatParam', 'PurifierLinkifyDocURL'); $this->docURL = $config->get('AutoFormatParam', 'PurifierLinkifyDocURL');
return parent::prepare($config, $context); return parent::prepare($config, $context);
} }

View File

@ -36,7 +36,7 @@ class HTMLPurifier_Language
*/ */
protected $config, $context; protected $config, $context;
public function __construct($config, &$context) { public function __construct($config, $context) {
$this->config = $config; $this->config = $config;
$this->context =& $context; $this->context =& $context;
} }

View File

@ -89,7 +89,7 @@ class HTMLPurifier_LanguageFactory
* @param $config Instance of HTMLPurifier_Config * @param $config Instance of HTMLPurifier_Config
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
*/ */
public function create($config, &$context) { public function create($config, $context) {
// validate language code // validate language code
$code = $this->validator->validate( $code = $this->validator->validate(

View File

@ -263,7 +263,7 @@ class HTMLPurifier_Lexer
* @param $string String HTML. * @param $string String HTML.
* @return HTMLPurifier_Token array representation of HTML. * @return HTMLPurifier_Token array representation of HTML.
*/ */
public function tokenizeHTML($string, $config, &$context) { public function tokenizeHTML($string, $config, $context) {
trigger_error('Call to abstract class', E_USER_ERROR); trigger_error('Call to abstract class', E_USER_ERROR);
} }
@ -311,7 +311,7 @@ class HTMLPurifier_Lexer
* encoding, extracting bits, and other good stuff. * encoding, extracting bits, and other good stuff.
* @todo Consider making protected * @todo Consider making protected
*/ */
public function normalize($html, $config, &$context) { public function normalize($html, $config, $context) {
// extract body from document if applicable // extract body from document if applicable
if ($config->get('Core', 'ConvertDocumentToFragment')) { if ($config->get('Core', 'ConvertDocumentToFragment')) {

View File

@ -38,7 +38,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
$this->factory = new HTMLPurifier_TokenFactory(); $this->factory = new HTMLPurifier_TokenFactory();
} }
public function tokenizeHTML($html, $config, &$context) { public function tokenizeHTML($html, $config, $context) {
$html = $this->normalize($html, $config, $context); $html = $this->normalize($html, $config, $context);
@ -173,7 +173,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
/** /**
* Wraps an HTML fragment in the necessary HTML * Wraps an HTML fragment in the necessary HTML
*/ */
protected function wrapHTML($html, $config, &$context) { protected function wrapHTML($html, $config, $context) {
$def = $config->getDefinition('HTML'); $def = $config->getDefinition('HTML');
$ret = ''; $ret = '';

View File

@ -42,7 +42,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
return $matches[1] . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8') . $matches[3]; return $matches[1] . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8') . $matches[3];
} }
public function tokenizeHTML($html, $config, &$context) { public function tokenizeHTML($html, $config, $context) {
// special normalization for script tags without any armor // special normalization for script tags without any armor
// our "armor" heurstic is a < sign any number of whitespaces after // our "armor" heurstic is a < sign any number of whitespaces after
@ -340,7 +340,7 @@ class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
* @param $string Inside of tag excluding name. * @param $string Inside of tag excluding name.
* @returns Assoc array of attributes. * @returns Assoc array of attributes.
*/ */
public function parseAttributeString($string, $config, &$context) { public function parseAttributeString($string, $config, $context) {
$string = (string) $string; // quick typecast $string = (string) $string; // quick typecast
if ($string == '') return array(); // no attributes if ($string == '') return array(); // no attributes

View File

@ -30,7 +30,7 @@ class HTMLPurifier_Lexer_PEARSax3 extends HTMLPurifier_Lexer
*/ */
protected $tokens = array(); protected $tokens = array();
public function tokenizeHTML($string, $config, &$context) { public function tokenizeHTML($string, $config, $context) {
$this->tokens = array(); $this->tokens = array();

View File

@ -10,7 +10,7 @@ require_once 'HTMLPurifier/Lexer/DOMLex.php';
class HTMLPurifier_Lexer_PH5P extends HTMLPurifier_Lexer_DOMLex { class HTMLPurifier_Lexer_PH5P extends HTMLPurifier_Lexer_DOMLex {
public function tokenizeHTML($html, $config, &$context) { public function tokenizeHTML($html, $config, $context) {
$html = $this->normalize($html, $config, $context); $html = $this->normalize($html, $config, $context);
$html = $this->wrapHTML( $html, $config, $context); $html = $this->wrapHTML( $html, $config, $context);
$parser = new HTML5($html); $parser = new HTML5($html);

View File

@ -24,7 +24,7 @@ abstract class HTMLPurifier_Strategy
* @param $config Configuration options * @param $config Configuration options
* @returns Processed array of token objects. * @returns Processed array of token objects.
*/ */
abstract public function execute($tokens, $config, &$context); abstract public function execute($tokens, $config, $context);
} }

View File

@ -16,7 +16,7 @@ abstract class HTMLPurifier_Strategy_Composite extends HTMLPurifier_Strategy
abstract public function __construct(); abstract public function __construct();
public function execute($tokens, $config, &$context) { public function execute($tokens, $config, $context) {
foreach ($this->strategies as $strategy) { foreach ($this->strategies as $strategy) {
$tokens = $strategy->execute($tokens, $config, $context); $tokens = $strategy->execute($tokens, $config, $context);
} }

View File

@ -34,7 +34,7 @@ require_once 'HTMLPurifier/HTMLDefinition.php';
class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
{ {
public function execute($tokens, $config, &$context) { public function execute($tokens, $config, $context) {
//####################################################################// //####################################################################//
// Pre-processing // Pre-processing

View File

@ -31,7 +31,7 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
protected $inputTokens, $inputIndex, $outputTokens, $currentNesting, protected $inputTokens, $inputIndex, $outputTokens, $currentNesting,
$currentInjector, $injectors; $currentInjector, $injectors;
public function execute($tokens, $config, &$context) { public function execute($tokens, $config, $context) {
$definition = $config->getHTMLDefinition(); $definition = $config->getHTMLDefinition();
@ -280,7 +280,7 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
return $result; return $result;
} }
function processToken($token, $config, &$context) { function processToken($token, $config, $context) {
if (is_array($token)) { if (is_array($token)) {
// the original token was overloaded by an injector, time // the original token was overloaded by an injector, time
// to some fancy acrobatics // to some fancy acrobatics

View File

@ -55,7 +55,7 @@ HTMLPurifier_ConfigSchema::define(
class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy class HTMLPurifier_Strategy_RemoveForeignElements extends HTMLPurifier_Strategy
{ {
public function execute($tokens, $config, &$context) { public function execute($tokens, $config, $context) {
$definition = $config->getHTMLDefinition(); $definition = $config->getHTMLDefinition();
$generator = new HTMLPurifier_Generator(); $generator = new HTMLPurifier_Generator();
$result = array(); $result = array();

View File

@ -13,7 +13,7 @@ require_once 'HTMLPurifier/AttrValidator.php';
class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
{ {
public function execute($tokens, $config, &$context) { public function execute($tokens, $config, $context) {
// setup validator // setup validator
$validator = new HTMLPurifier_AttrValidator(); $validator = new HTMLPurifier_AttrValidator();

View File

@ -19,7 +19,7 @@ abstract class HTMLPurifier_TagTransform
* @param $config Mandatory HTMLPurifier_Config object * @param $config Mandatory HTMLPurifier_Config object
* @param $context Mandatory HTMLPurifier_Context object * @param $context Mandatory HTMLPurifier_Context object
*/ */
abstract public function transform($tag, $config, &$context); abstract public function transform($tag, $config, $context);
/** /**
* Prepends CSS properties to the style attribute, creating the * Prepends CSS properties to the style attribute, creating the

View File

@ -36,7 +36,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
'+4' => '300%' '+4' => '300%'
); );
public function transform($tag, $config, &$context) { public function transform($tag, $config, $context) {
if ($tag->type == 'end') { if ($tag->type == 'end') {
$new_tag = $tag->copy(); $new_tag = $tag->copy();

View File

@ -21,7 +21,7 @@ class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform
$this->style = $style; $this->style = $style;
} }
public function transform($tag, $config, &$context) { public function transform($tag, $config, $context) {
$new_tag = $tag->copy(); $new_tag = $tag->copy();
$new_tag->name = $this->transform_to; $new_tag->name = $this->transform_to;
if (!is_null($this->style) && if (!is_null($this->style) &&

View File

@ -30,8 +30,8 @@ class HTMLPurifier_URI
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
* @return Scheme object appropriate for validating this URI * @return Scheme object appropriate for validating this URI
*/ */
public function getSchemeObj($config, &$context) { public function getSchemeObj($config, $context) {
$registry =& HTMLPurifier_URISchemeRegistry::instance(); $registry = HTMLPurifier_URISchemeRegistry::instance();
if ($this->scheme !== null) { if ($this->scheme !== null) {
$scheme_obj = $registry->getScheme($this->scheme, $config, $context); $scheme_obj = $registry->getScheme($this->scheme, $config, $context);
if (!$scheme_obj) return false; // invalid scheme, clean it out if (!$scheme_obj) return false; // invalid scheme, clean it out
@ -57,7 +57,7 @@ class HTMLPurifier_URI
* @param $context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
* @return True if validation/filtering succeeds, false if failure * @return True if validation/filtering succeeds, false if failure
*/ */
public function validate($config, &$context) { public function validate($config, $context) {
// validate host // validate host
if (!is_null($this->host)) { if (!is_null($this->host)) {

View File

@ -134,7 +134,7 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI', 'DefaultScheme'); if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI', 'DefaultScheme');
} }
public function filter(&$uri, $config, &$context) { public function filter(&$uri, $config, $context) {
foreach ($this->filters as $name => $x) { foreach ($this->filters as $name => $x) {
$result = $this->filters[$name]->filter($uri, $config, $context); $result = $this->filters[$name]->filter($uri, $config, $context);
if (!$result) return false; if (!$result) return false;

View File

@ -28,11 +28,11 @@ abstract class HTMLPurifier_URIFilter
* Filter a URI object * Filter a URI object
* @param &$uri Reference to URI object * @param &$uri Reference to URI object
* @param $config Instance of HTMLPurifier_Config * @param $config Instance of HTMLPurifier_Config
* @param &$context Instance of HTMLPurifier_Context * @param $context Instance of HTMLPurifier_Context
* @return bool Whether or not to continue processing: false indicates * @return bool Whether or not to continue processing: false indicates
* URL is no good, true indicates continue processing. Note that * URL is no good, true indicates continue processing. Note that
* all changes are committed directly on the URI object * all changes are committed directly on the URI object
*/ */
abstract public function filter(&$uri, $config, &$context); abstract public function filter(&$uri, $config, $context);
} }

View File

@ -20,7 +20,7 @@ class HTMLPurifier_URIFilter_DisableExternal extends HTMLPurifier_URIFilter
$our_host = $config->get('URI', 'Host'); $our_host = $config->get('URI', 'Host');
if ($our_host !== null) $this->ourHostParts = array_reverse(explode('.', $our_host)); if ($our_host !== null) $this->ourHostParts = array_reverse(explode('.', $our_host));
} }
public function filter(&$uri, $config, &$context) { public function filter(&$uri, $config, $context) {
if (is_null($uri->host)) return true; if (is_null($uri->host)) return true;
if ($this->ourHostParts === false) return false; if ($this->ourHostParts === false) return false;
$host_parts = array_reverse(explode('.', $uri->host)); $host_parts = array_reverse(explode('.', $uri->host));

View File

@ -18,7 +18,7 @@ HTMLPurifier_ConfigSchema::define(
class HTMLPurifier_URIFilter_DisableExternalResources extends HTMLPurifier_URIFilter_DisableExternal class HTMLPurifier_URIFilter_DisableExternalResources extends HTMLPurifier_URIFilter_DisableExternal
{ {
public $name = 'DisableExternalResources'; public $name = 'DisableExternalResources';
public function filter(&$uri, $config, &$context) { public function filter(&$uri, $config, $context) {
if (!$context->get('EmbeddedURI', true)) return true; if (!$context->get('EmbeddedURI', true)) return true;
return parent::filter($uri, $config, $context); return parent::filter($uri, $config, $context);
} }

View File

@ -17,7 +17,7 @@ class HTMLPurifier_URIFilter_HostBlacklist extends HTMLPurifier_URIFilter
public function prepare($config) { public function prepare($config) {
$this->blacklist = $config->get('URI', 'HostBlacklist'); $this->blacklist = $config->get('URI', 'HostBlacklist');
} }
public function filter(&$uri, $config, &$context) { public function filter(&$uri, $config, $context) {
foreach($this->blacklist as $blacklisted_host_fragment) { foreach($this->blacklist as $blacklisted_host_fragment) {
if (strpos($uri->host, $blacklisted_host_fragment) !== false) { if (strpos($uri->host, $blacklisted_host_fragment) !== false) {
return false; return false;

View File

@ -33,7 +33,7 @@ class HTMLPurifier_URIFilter_MakeAbsolute extends HTMLPurifier_URIFilter
$stack = $this->_collapseStack($stack); // do pre-parsing $stack = $this->_collapseStack($stack); // do pre-parsing
$this->basePathStack = $stack; $this->basePathStack = $stack;
} }
public function filter(&$uri, $config, &$context) { public function filter(&$uri, $config, $context) {
if (is_null($this->base)) return true; // abort early if (is_null($this->base)) return true; // abort early
if ( if (
$uri->path === '' && is_null($uri->scheme) && $uri->path === '' && is_null($uri->scheme) &&

View File

@ -32,7 +32,7 @@ class HTMLPurifier_URIScheme
* @param $context HTMLPurifier_Context object * @param $context HTMLPurifier_Context object
* @return Bool success or failure * @return Bool success or failure
*/ */
public function validate(&$uri, $config, &$context) { public function validate(&$uri, $config, $context) {
if ($this->default_port == $uri->port) $uri->port = null; if ($this->default_port == $uri->port) $uri->port = null;
return true; return true;
} }

View File

@ -11,7 +11,7 @@ class HTMLPurifier_URIScheme_ftp extends HTMLPurifier_URIScheme {
public $browsable = true; // usually public $browsable = true; // usually
public $hierarchical = true; public $hierarchical = true;
public function validate(&$uri, $config, &$context) { public function validate(&$uri, $config, $context) {
parent::validate($uri, $config, $context); parent::validate($uri, $config, $context);
$uri->query = null; $uri->query = null;

View File

@ -11,7 +11,7 @@ class HTMLPurifier_URIScheme_http extends HTMLPurifier_URIScheme {
public $browsable = true; public $browsable = true;
public $hierarchical = true; public $hierarchical = true;
public function validate(&$uri, $config, &$context) { public function validate(&$uri, $config, $context) {
parent::validate($uri, $config, $context); parent::validate($uri, $config, $context);
$uri->userinfo = null; $uri->userinfo = null;
return true; return true;

View File

@ -15,7 +15,7 @@ class HTMLPurifier_URIScheme_mailto extends HTMLPurifier_URIScheme {
public $browsable = false; public $browsable = false;
public function validate(&$uri, $config, &$context) { public function validate(&$uri, $config, $context) {
parent::validate($uri, $config, $context); parent::validate($uri, $config, $context);
$uri->userinfo = null; $uri->userinfo = null;
$uri->host = null; $uri->host = null;

View File

@ -9,7 +9,7 @@ class HTMLPurifier_URIScheme_news extends HTMLPurifier_URIScheme {
public $browsable = false; public $browsable = false;
public function validate(&$uri, $config, &$context) { public function validate(&$uri, $config, $context) {
parent::validate($uri, $config, $context); parent::validate($uri, $config, $context);
$uri->userinfo = null; $uri->userinfo = null;
$uri->host = null; $uri->host = null;

View File

@ -10,7 +10,7 @@ class HTMLPurifier_URIScheme_nntp extends HTMLPurifier_URIScheme {
public $default_port = 119; public $default_port = 119;
public $browsable = false; public $browsable = false;
public function validate(&$uri, $config, &$context) { public function validate(&$uri, $config, $context) {
parent::validate($uri, $config, $context); parent::validate($uri, $config, $context);
$uri->userinfo = null; $uri->userinfo = null;
$uri->query = null; $uri->query = null;

View File

@ -43,7 +43,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.
*/ */
public static function &instance($prototype = null) { public static function instance($prototype = null) {
static $instance = null; static $instance = null;
if ($prototype !== null) { if ($prototype !== null) {
$instance = $prototype; $instance = $prototype;
@ -64,7 +64,7 @@ class HTMLPurifier_URISchemeRegistry
* @param $config HTMLPurifier_Config object * @param $config HTMLPurifier_Config object
* @param $config HTMLPurifier_Context object * @param $config HTMLPurifier_Context object
*/ */
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 $null = null; // for the sake of passing by reference
@ -90,8 +90,8 @@ class HTMLPurifier_URISchemeRegistry
* @param $scheme Scheme name * @param $scheme Scheme name
* @param $scheme_obj HTMLPurifier_URIScheme object * @param $scheme_obj HTMLPurifier_URIScheme object
*/ */
public function register($scheme, &$scheme_obj) { public function register($scheme, $scheme_obj) {
$this->schemes[$scheme] =& $scheme_obj; $this->schemes[$scheme] = $scheme_obj;
} }
} }

View File

@ -23,21 +23,21 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
$this->oldRegistry = HTMLPurifier_URISchemeRegistry::instance(); $this->oldRegistry = HTMLPurifier_URISchemeRegistry::instance();
generate_mock_once('HTMLPurifier_URIScheme'); generate_mock_once('HTMLPurifier_URIScheme');
generate_mock_once('HTMLPurifier_URISchemeRegistry'); generate_mock_once('HTMLPurifier_URISchemeRegistry');
$registry =& HTMLPurifier_URISchemeRegistry::instance( $registry = HTMLPurifier_URISchemeRegistry::instance(
new HTMLPurifier_URISchemeRegistryMock() new HTMLPurifier_URISchemeRegistryMock()
); );
return $registry; return $registry;
} }
function &setUpSchemeMock($name) { function setUpSchemeMock($name) {
$registry =& $this->setUpSchemeRegistryMock(); $registry = $this->setUpSchemeRegistryMock();
$scheme_mock = new HTMLPurifier_URISchemeMock(); $scheme_mock = new HTMLPurifier_URISchemeMock();
$registry->setReturnValue('getScheme', $scheme_mock, array($name, '*', '*')); $registry->setReturnValue('getScheme', $scheme_mock, array($name, '*', '*'));
return $scheme_mock; return $scheme_mock;
} }
function setUpNoValidSchemes() { function setUpNoValidSchemes() {
$registry =& $this->setUpSchemeRegistryMock(); $registry = $this->setUpSchemeRegistryMock();
$registry->setReturnValue('getScheme', false, array('*', '*', '*')); $registry->setReturnValue('getScheme', false, array('*', '*', '*'));
} }
@ -46,7 +46,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
} }
function test_getSchemeObj() { function test_getSchemeObj() {
$scheme_mock =& $this->setUpSchemeMock('http'); $scheme_mock = $this->setUpSchemeMock('http');
$uri = $this->createURI('http:'); $uri = $this->createURI('http:');
$scheme_obj = $uri->getSchemeObj($this->config, $this->context); $scheme_obj = $uri->getSchemeObj($this->config, $this->context);
@ -68,7 +68,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
function test_getSchemaObj_defaultScheme() { function test_getSchemaObj_defaultScheme() {
$scheme = 'foobar'; $scheme = 'foobar';
$scheme_mock =& $this->setUpSchemeMock($scheme); $scheme_mock = $this->setUpSchemeMock($scheme);
$this->config->set('URI', 'DefaultScheme', $scheme); $this->config->set('URI', 'DefaultScheme', $scheme);
$uri = $this->createURI('hmm'); $uri = $this->createURI('hmm');

Some files were not shown because too many files have changed in this diff Show More