From 12185143ef8720f0d45894ecbeee6773d9cd4134 Mon Sep 17 00:00:00 2001 From: "f.godfrin" Date: Fri, 10 Feb 2017 21:03:11 +0100 Subject: [PATCH] Use a constructor and a property for the alpha check --- library/HTMLPurifier/AttrDef/CSS/Color.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/library/HTMLPurifier/AttrDef/CSS/Color.php b/library/HTMLPurifier/AttrDef/CSS/Color.php index 2773487f..cecfbb8c 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Color.php +++ b/library/HTMLPurifier/AttrDef/CSS/Color.php @@ -7,6 +7,16 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef { /** + * @type HTMLPurifier_AttrDef_CSS_AlphaValue + */ + protected $alpha; + + public function __construct() + { + $this->alpha = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + } + + /** * @param string $color * @param HTMLPurifier_Config $config * @param HTMLPurifier_Context $context @@ -86,7 +96,7 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef // different check for alpha channel if ($alpha_channel === true && $i === count($parts)) { - $result = (new HTMLPurifier_AttrDef_CSS_AlphaValue())->validate($part, $config, $context); + $result = $this->alpha->validate($part, $config, $context); if ($result === false) { return false; @@ -145,6 +155,7 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef } return $color; } + } // vim: et sw=4 sts=4 -- 2.11.4.GIT