diff --git a/library/HTMLPurifier/AttrDef/CSS/Color.php b/library/HTMLPurifier/AttrDef/CSS/Color.php
index 4e6a78ac..4f8ed1fd 100644
--- a/library/HTMLPurifier/AttrDef/CSS/Color.php
+++ b/library/HTMLPurifier/AttrDef/CSS/Color.php
@@ -8,37 +8,33 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
{
- /**
- * Color keyword lookup table.
- * @todo Extend it to include all usually allowed colors.
- */
- var $colors = array(
- 'maroon' => '#800000',
- 'red' => '#F00',
- 'orange' => '#FFA500',
- 'yellow' => '#FF0',
- 'olive' => '#808000',
- 'purple' => '#800080',
- 'fuchsia' => '#F0F',
- 'white' => '#FFF',
- 'lime' => '#0F0',
- 'green' => '#008000',
- 'navy' => '#000080',
- 'blue' => '#00F',
- 'aqua' => '#0FF',
- 'teal' => '#008080',
- 'black' => '#000',
- 'silver' => '#C0C0C0',
- 'gray' => '#808080'
- );
-
function validate($color, $config, &$context) {
+ static $colors = array(
+ 'maroon' => '#800000',
+ 'red' => '#F00',
+ 'orange' => '#FFA500',
+ 'yellow' => '#FF0',
+ 'olive' => '#808000',
+ 'purple' => '#800080',
+ 'fuchsia' => '#F0F',
+ 'white' => '#FFF',
+ 'lime' => '#0F0',
+ 'green' => '#008000',
+ 'navy' => '#000080',
+ 'blue' => '#00F',
+ 'aqua' => '#0FF',
+ 'teal' => '#008080',
+ 'black' => '#000',
+ 'silver' => '#C0C0C0',
+ 'gray' => '#808080'
+ );
+
$color = trim($color);
if (!$color) return false;
$lower = strtolower($color);
- if (isset($this->colors[$lower])) return $this->colors[$lower];
+ if (isset($colors[$lower])) return $colors[$lower];
if ($color[0] === '#') {
// hexadecimal handling
diff --git a/library/HTMLPurifier/AttrDef/CSS/Font.php b/library/HTMLPurifier/AttrDef/CSS/Font.php
index 1b3b0905..34dfa19a 100644
--- a/library/HTMLPurifier/AttrDef/CSS/Font.php
+++ b/library/HTMLPurifier/AttrDef/CSS/Font.php
@@ -18,18 +18,6 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef
*/
var $info = array();
- /**
- * System font keywords.
- */
- var $system_fonts = array(
- 'caption' => true,
- 'icon' => true,
- 'menu' => true,
- 'message-box' => true,
- 'small-caption' => true,
- 'status-bar' => true
- );
-
function HTMLPurifier_AttrDef_CSS_Font($config) {
$def = $config->getCSSDefinition();
$this->info['font-style'] = $def->info['font-style'];
@@ -42,13 +30,22 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef
function validate($string, $config, &$context) {
+ static $system_fonts = array(
+ 'caption' => true,
+ 'icon' => true,
+ 'menu' => true,
+ 'message-box' => true,
+ 'small-caption' => true,
+ 'status-bar' => true
+ );
+
// regular pre-processing
$string = $this->parseCDATA($string);
if ($string === '') return false;
// check if it's one of the keywords
$lowercase_string = strtolower($string);
- if (isset($this->system_fonts[$lowercase_string])) {
+ if (isset($system_fonts[$lowercase_string])) {
return $lowercase_string;
}
diff --git a/library/HTMLPurifier/AttrDef/CSS/FontFamily.php b/library/HTMLPurifier/AttrDef/CSS/FontFamily.php
index 15cbbf39..ab6d9d8b 100644
--- a/library/HTMLPurifier/AttrDef/CSS/FontFamily.php
+++ b/library/HTMLPurifier/AttrDef/CSS/FontFamily.php
@@ -10,19 +10,15 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
{
- /**
- * Generic font family keywords.
- * @protected
- */
- var $generic_names = array(
- 'serif' => true,
- 'sans-serif' => true,
- 'monospace' => true,
- 'fantasy' => true,
- 'cursive' => true
- );
-
function validate($string, $config, &$context) {
+ static $generic_names = array(
+ 'serif' => true,
+ 'sans-serif' => true,
+ 'monospace' => true,
+ 'fantasy' => true,
+ 'cursive' => true
+ );
+
$string = $this->parseCDATA($string);
// assume that no font names contain commas in them
$fonts = explode(',', $string);
@@ -31,7 +27,7 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
$font = trim($font);
if ($font === '') continue;
// match a generic name
- if (isset($this->generic_names[$font])) {
+ if (isset($generic_names[$font])) {
$final .= $font . ', ';
continue;
}
diff --git a/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php
index 294dd830..a5d82d10 100644
--- a/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php
+++ b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php
@@ -10,23 +10,19 @@ require_once 'HTMLPurifier/AttrDef.php';
class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
{
- /**
- * Lookup table of allowed values.
- * @protected
- */
- var $allowed_values = array(
- 'line-through' => true,
- 'overline' => true,
- 'underline' => true
- );
-
function validate($string, $config, &$context) {
+ static $allowed_values = array(
+ 'line-through' => true,
+ 'overline' => true,
+ 'underline' => true
+ );
+
$string = strtolower($this->parseCDATA($string));
$parts = explode(' ', $string);
$final = '';
foreach ($parts as $part) {
- if (isset($this->allowed_values[$part])) {
+ if (isset($allowed_values[$part])) {
$final .= $part . ' ';
}
}
diff --git a/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php b/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php
index 94a47ba9..854f88e5 100644
--- a/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php
+++ b/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php
@@ -26,22 +26,20 @@ HTMLPurifier_ConfigSchema::define(
class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
{
- /** Lookup array of attribute names to configuration name */
- var $configLookup = array(
- 'rel' => 'AllowedRel',
- 'rev' => 'AllowedRev'
- );
-
/** Name config attribute to pull. */
var $name;
function HTMLPurifier_AttrDef_HTML_LinkTypes($name) {
- if (!isset($this->configLookup[$name])) {
+ $configLookup = array(
+ 'rel' => 'AllowedRel',
+ 'rev' => 'AllowedRev'
+ );
+ if (!isset($configLookup[$name])) {
trigger_error('Unrecognized attribute name for link '.
'relationship.', E_USER_ERROR);
return;
}
- $this->name = $this->configLookup[$name];
+ $this->name = $configLookup[$name];
}
function validate($string, $config, &$context) {
diff --git a/library/HTMLPurifier/AttrDef/URI.php b/library/HTMLPurifier/AttrDef/URI.php
index 71027181..fdaa35bb 100644
--- a/library/HTMLPurifier/AttrDef/URI.php
+++ b/library/HTMLPurifier/AttrDef/URI.php
@@ -93,7 +93,6 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
{
var $host;
- var $PercentEncoder;
var $embeds_resource;
/**
@@ -101,12 +100,14 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
*/
function HTMLPurifier_AttrDef_URI($embeds_resource = false) {
$this->host = new HTMLPurifier_AttrDef_URI_Host();
- $this->PercentEncoder = new HTMLPurifier_PercentEncoder();
$this->embeds_resource = (bool) $embeds_resource;
}
function validate($uri, $config, &$context) {
+ static $PercentEncoder = null;
+ if ($PercentEncoder === null) $PercentEncoder = new HTMLPurifier_PercentEncoder();
+
// We'll write stack-based parsers later, for now, use regexps to
// get things working as fast as possible (irony)
@@ -116,7 +117,7 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
$uri = $this->parseCDATA($uri);
// fix up percent-encoding
- $uri = $this->PercentEncoder->normalize($uri);
+ $uri = $PercentEncoder->normalize($uri);
// while it would be nice to use parse_url(), that's specifically
// for HTTP and thus won't work for our generic URI parsing