@@ -11,32 +11,32 @@ |
||
| 11 | 11 | class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - public function transform($attr, $config, $context) { |
|
| 15 | - |
|
| 16 | - $src = true; |
|
| 17 | - if (!isset($attr['src'])) { |
|
| 18 | - if ($config->get('Core.RemoveInvalidImg')) return $attr; |
|
| 19 | - $attr['src'] = $config->get('Attr.DefaultInvalidImage'); |
|
| 20 | - $src = false; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if (!isset($attr['alt'])) { |
|
| 24 | - if ($src) { |
|
| 25 | - $alt = $config->get('Attr.DefaultImageAlt'); |
|
| 26 | - if ($alt === null) { |
|
| 27 | - // truncate if the alt is too long |
|
| 28 | - $attr['alt'] = substr(basename($attr['src']),0,40); |
|
| 29 | - } else { |
|
| 30 | - $attr['alt'] = $alt; |
|
| 31 | - } |
|
| 32 | - } else { |
|
| 33 | - $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt'); |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - return $attr; |
|
| 38 | - |
|
| 39 | - } |
|
| 14 | + public function transform($attr, $config, $context) { |
|
| 15 | + |
|
| 16 | + $src = true; |
|
| 17 | + if (!isset($attr['src'])) { |
|
| 18 | + if ($config->get('Core.RemoveInvalidImg')) return $attr; |
|
| 19 | + $attr['src'] = $config->get('Attr.DefaultInvalidImage'); |
|
| 20 | + $src = false; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if (!isset($attr['alt'])) { |
|
| 24 | + if ($src) { |
|
| 25 | + $alt = $config->get('Attr.DefaultImageAlt'); |
|
| 26 | + if ($alt === null) { |
|
| 27 | + // truncate if the alt is too long |
|
| 28 | + $attr['alt'] = substr(basename($attr['src']),0,40); |
|
| 29 | + } else { |
|
| 30 | + $attr['alt'] = $alt; |
|
| 31 | + } |
|
| 32 | + } else { |
|
| 33 | + $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt'); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return $attr; |
|
| 38 | + |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | $alt = $config->get('Attr.DefaultImageAlt'); |
| 26 | 26 | if ($alt === null) { |
| 27 | 27 | // truncate if the alt is too long |
| 28 | - $attr['alt'] = substr(basename($attr['src']),0,40); |
|
| 28 | + $attr['alt'] = substr(basename($attr['src']), 0, 40); |
|
| 29 | 29 | } else { |
| 30 | 30 | $attr['alt'] = $alt; |
| 31 | 31 | } |
@@ -15,7 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | $src = true; |
| 17 | 17 | if (!isset($attr['src'])) { |
| 18 | - if ($config->get('Core.RemoveInvalidImg')) return $attr; |
|
| 18 | + if ($config->get('Core.RemoveInvalidImg')) { |
|
| 19 | + return $attr; |
|
| 20 | + } |
|
| 19 | 21 | $attr['src'] = $config->get('Attr.DefaultInvalidImage'); |
| 20 | 22 | $src = false; |
| 21 | 23 | } |
@@ -5,39 +5,39 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class HTMLPurifier_AttrTransform_ImgSpace extends HTMLPurifier_AttrTransform { |
| 7 | 7 | |
| 8 | - protected $attr; |
|
| 9 | - protected $css = array( |
|
| 10 | - 'hspace' => array('left', 'right'), |
|
| 11 | - 'vspace' => array('top', 'bottom') |
|
| 12 | - ); |
|
| 8 | + protected $attr; |
|
| 9 | + protected $css = array( |
|
| 10 | + 'hspace' => array('left', 'right'), |
|
| 11 | + 'vspace' => array('top', 'bottom') |
|
| 12 | + ); |
|
| 13 | 13 | |
| 14 | - public function __construct($attr) { |
|
| 15 | - $this->attr = $attr; |
|
| 16 | - if (!isset($this->css[$attr])) { |
|
| 17 | - trigger_error(htmlspecialchars($attr, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . ' is not valid space attribute'); |
|
| 18 | - } |
|
| 19 | - } |
|
| 14 | + public function __construct($attr) { |
|
| 15 | + $this->attr = $attr; |
|
| 16 | + if (!isset($this->css[$attr])) { |
|
| 17 | + trigger_error(htmlspecialchars($attr, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . ' is not valid space attribute'); |
|
| 18 | + } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function transform($attr, $config, $context) { |
|
| 21 | + public function transform($attr, $config, $context) { |
|
| 22 | 22 | |
| 23 | - if (!isset($attr[$this->attr])) return $attr; |
|
| 23 | + if (!isset($attr[$this->attr])) return $attr; |
|
| 24 | 24 | |
| 25 | - $width = $this->confiscateAttr($attr, $this->attr); |
|
| 26 | - // some validation could happen here |
|
| 25 | + $width = $this->confiscateAttr($attr, $this->attr); |
|
| 26 | + // some validation could happen here |
|
| 27 | 27 | |
| 28 | - if (!isset($this->css[$this->attr])) return $attr; |
|
| 28 | + if (!isset($this->css[$this->attr])) return $attr; |
|
| 29 | 29 | |
| 30 | - $style = ''; |
|
| 31 | - foreach ($this->css[$this->attr] as $suffix) { |
|
| 32 | - $property = "margin-$suffix"; |
|
| 33 | - $style .= "$property:{$width}px;"; |
|
| 34 | - } |
|
| 30 | + $style = ''; |
|
| 31 | + foreach ($this->css[$this->attr] as $suffix) { |
|
| 32 | + $property = "margin-$suffix"; |
|
| 33 | + $style .= "$property:{$width}px;"; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $this->prependCSS($attr, $style); |
|
| 36 | + $this->prependCSS($attr, $style); |
|
| 37 | 37 | |
| 38 | - return $attr; |
|
| 38 | + return $attr; |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -20,12 +20,16 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function transform($attr, $config, $context) { |
| 22 | 22 | |
| 23 | - if (!isset($attr[$this->attr])) return $attr; |
|
| 23 | + if (!isset($attr[$this->attr])) { |
|
| 24 | + return $attr; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | $width = $this->confiscateAttr($attr, $this->attr); |
| 26 | 28 | // some validation could happen here |
| 27 | 29 | |
| 28 | - if (!isset($this->css[$this->attr])) return $attr; |
|
| 30 | + if (!isset($this->css[$this->attr])) { |
|
| 31 | + return $attr; |
|
| 32 | + } |
|
| 29 | 33 | |
| 30 | 34 | $style = ''; |
| 31 | 35 | foreach ($this->css[$this->attr] as $suffix) { |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | public function __construct($attr) { |
| 15 | 15 | $this->attr = $attr; |
| 16 | 16 | if (!isset($this->css[$attr])) { |
| 17 | - trigger_error(htmlspecialchars($attr, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . ' is not valid space attribute'); |
|
| 17 | + trigger_error(htmlspecialchars($attr, ENT_COMPAT | ENT_HTML401, 'UTF-8', false).' is not valid space attribute'); |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
@@ -6,34 +6,34 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class HTMLPurifier_AttrTransform_Input extends HTMLPurifier_AttrTransform { |
| 8 | 8 | |
| 9 | - protected $pixels; |
|
| 9 | + protected $pixels; |
|
| 10 | 10 | |
| 11 | - public function __construct() { |
|
| 12 | - $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); |
|
| 13 | - } |
|
| 11 | + public function __construct() { |
|
| 12 | + $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function transform($attr, $config, $context) { |
|
| 16 | - if (!isset($attr['type'])) $t = 'text'; |
|
| 17 | - else $t = strtolower($attr['type']); |
|
| 18 | - if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { |
|
| 19 | - unset($attr['checked']); |
|
| 20 | - } |
|
| 21 | - if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') { |
|
| 22 | - unset($attr['maxlength']); |
|
| 23 | - } |
|
| 24 | - if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { |
|
| 25 | - $result = $this->pixels->validate($attr['size'], $config, $context); |
|
| 26 | - if ($result === false) unset($attr['size']); |
|
| 27 | - else $attr['size'] = $result; |
|
| 28 | - } |
|
| 29 | - if (isset($attr['src']) && $t !== 'image') { |
|
| 30 | - unset($attr['src']); |
|
| 31 | - } |
|
| 32 | - if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) { |
|
| 33 | - $attr['value'] = ''; |
|
| 34 | - } |
|
| 35 | - return $attr; |
|
| 36 | - } |
|
| 15 | + public function transform($attr, $config, $context) { |
|
| 16 | + if (!isset($attr['type'])) $t = 'text'; |
|
| 17 | + else $t = strtolower($attr['type']); |
|
| 18 | + if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { |
|
| 19 | + unset($attr['checked']); |
|
| 20 | + } |
|
| 21 | + if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') { |
|
| 22 | + unset($attr['maxlength']); |
|
| 23 | + } |
|
| 24 | + if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { |
|
| 25 | + $result = $this->pixels->validate($attr['size'], $config, $context); |
|
| 26 | + if ($result === false) unset($attr['size']); |
|
| 27 | + else $attr['size'] = $result; |
|
| 28 | + } |
|
| 29 | + if (isset($attr['src']) && $t !== 'image') { |
|
| 30 | + unset($attr['src']); |
|
| 31 | + } |
|
| 32 | + if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) { |
|
| 33 | + $attr['value'] = ''; |
|
| 34 | + } |
|
| 35 | + return $attr; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -13,8 +13,11 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function transform($attr, $config, $context) { |
| 16 | - if (!isset($attr['type'])) $t = 'text'; |
|
| 17 | - else $t = strtolower($attr['type']); |
|
| 16 | + if (!isset($attr['type'])) { |
|
| 17 | + $t = 'text'; |
|
| 18 | + } else { |
|
| 19 | + $t = strtolower($attr['type']); |
|
| 20 | + } |
|
| 18 | 21 | if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { |
| 19 | 22 | unset($attr['checked']); |
| 20 | 23 | } |
@@ -23,8 +26,11 @@ discard block |
||
| 23 | 26 | } |
| 24 | 27 | if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { |
| 25 | 28 | $result = $this->pixels->validate($attr['size'], $config, $context); |
| 26 | - if ($result === false) unset($attr['size']); |
|
| 27 | - else $attr['size'] = $result; |
|
| 29 | + if ($result === false) { |
|
| 30 | + unset($attr['size']); |
|
| 31 | + } else { |
|
| 32 | + $attr['size'] = $result; |
|
| 33 | + } |
|
| 28 | 34 | } |
| 29 | 35 | if (isset($attr['src']) && $t !== 'image') { |
| 30 | 36 | unset($attr['src']); |
@@ -8,20 +8,20 @@ |
||
| 8 | 8 | class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - public function transform($attr, $config, $context) { |
|
| 11 | + public function transform($attr, $config, $context) { |
|
| 12 | 12 | |
| 13 | - $lang = isset($attr['lang']) ? $attr['lang'] : false; |
|
| 14 | - $xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false; |
|
| 13 | + $lang = isset($attr['lang']) ? $attr['lang'] : false; |
|
| 14 | + $xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false; |
|
| 15 | 15 | |
| 16 | - if ($lang !== false && $xml_lang === false) { |
|
| 17 | - $attr['xml:lang'] = $lang; |
|
| 18 | - } elseif ($xml_lang !== false) { |
|
| 19 | - $attr['lang'] = $xml_lang; |
|
| 20 | - } |
|
| 16 | + if ($lang !== false && $xml_lang === false) { |
|
| 17 | + $attr['xml:lang'] = $lang; |
|
| 18 | + } elseif ($xml_lang !== false) { |
|
| 19 | + $attr['lang'] = $xml_lang; |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - return $attr; |
|
| 22 | + return $attr; |
|
| 23 | 23 | |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
@@ -6,21 +6,21 @@ |
||
| 6 | 6 | class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $name; |
|
| 10 | - protected $cssName; |
|
| 9 | + protected $name; |
|
| 10 | + protected $cssName; |
|
| 11 | 11 | |
| 12 | - public function __construct($name, $css_name = null) { |
|
| 13 | - $this->name = $name; |
|
| 14 | - $this->cssName = $css_name ? $css_name : $name; |
|
| 15 | - } |
|
| 12 | + public function __construct($name, $css_name = null) { |
|
| 13 | + $this->name = $name; |
|
| 14 | + $this->cssName = $css_name ? $css_name : $name; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function transform($attr, $config, $context) { |
|
| 18 | - if (!isset($attr[$this->name])) return $attr; |
|
| 19 | - $length = $this->confiscateAttr($attr, $this->name); |
|
| 20 | - if(ctype_digit($length)) $length .= 'px'; |
|
| 21 | - $this->prependCSS($attr, $this->cssName . ":$length;"); |
|
| 22 | - return $attr; |
|
| 23 | - } |
|
| 17 | + public function transform($attr, $config, $context) { |
|
| 18 | + if (!isset($attr[$this->name])) return $attr; |
|
| 19 | + $length = $this->confiscateAttr($attr, $this->name); |
|
| 20 | + if(ctype_digit($length)) $length .= 'px'; |
|
| 21 | + $this->prependCSS($attr, $this->cssName . ":$length;"); |
|
| 22 | + return $attr; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -15,9 +15,13 @@ |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function transform($attr, $config, $context) { |
| 18 | - if (!isset($attr[$this->name])) return $attr; |
|
| 18 | + if (!isset($attr[$this->name])) { |
|
| 19 | + return $attr; |
|
| 20 | + } |
|
| 19 | 21 | $length = $this->confiscateAttr($attr, $this->name); |
| 20 | - if(ctype_digit($length)) $length .= 'px'; |
|
| 22 | + if(ctype_digit($length)) { |
|
| 23 | + $length .= 'px'; |
|
| 24 | + } |
|
| 21 | 25 | $this->prependCSS($attr, $this->cssName . ":$length;"); |
| 22 | 26 | return $attr; |
| 23 | 27 | } |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | public function transform($attr, $config, $context) { |
| 18 | 18 | if (!isset($attr[$this->name])) return $attr; |
| 19 | 19 | $length = $this->confiscateAttr($attr, $this->name); |
| 20 | - if(ctype_digit($length)) $length .= 'px'; |
|
| 21 | - $this->prependCSS($attr, $this->cssName . ":$length;"); |
|
| 20 | + if (ctype_digit($length)) $length .= 'px'; |
|
| 21 | + $this->prependCSS($attr, $this->cssName.":$length;"); |
|
| 22 | 22 | return $attr; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function transform($attr, $config, $context) { |
|
| 10 | - // Abort early if we're using relaxed definition of name |
|
| 11 | - if ($config->get('HTML.Attr.Name.UseCDATA')) return $attr; |
|
| 12 | - if (!isset($attr['name'])) return $attr; |
|
| 13 | - $id = $this->confiscateAttr($attr, 'name'); |
|
| 14 | - if ( isset($attr['id'])) return $attr; |
|
| 15 | - $attr['id'] = $id; |
|
| 16 | - return $attr; |
|
| 17 | - } |
|
| 9 | + public function transform($attr, $config, $context) { |
|
| 10 | + // Abort early if we're using relaxed definition of name |
|
| 11 | + if ($config->get('HTML.Attr.Name.UseCDATA')) return $attr; |
|
| 12 | + if (!isset($attr['name'])) return $attr; |
|
| 13 | + $id = $this->confiscateAttr($attr, 'name'); |
|
| 14 | + if ( isset($attr['id'])) return $attr; |
|
| 15 | + $attr['id'] = $id; |
|
| 16 | + return $attr; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | } |
| 20 | 20 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | if ($config->get('HTML.Attr.Name.UseCDATA')) return $attr; |
| 12 | 12 | if (!isset($attr['name'])) return $attr; |
| 13 | 13 | $id = $this->confiscateAttr($attr, 'name'); |
| 14 | - if ( isset($attr['id'])) return $attr; |
|
| 14 | + if (isset($attr['id'])) return $attr; |
|
| 15 | 15 | $attr['id'] = $id; |
| 16 | 16 | return $attr; |
| 17 | 17 | } |
@@ -8,10 +8,16 @@ |
||
| 8 | 8 | |
| 9 | 9 | public function transform($attr, $config, $context) { |
| 10 | 10 | // Abort early if we're using relaxed definition of name |
| 11 | - if ($config->get('HTML.Attr.Name.UseCDATA')) return $attr; |
|
| 12 | - if (!isset($attr['name'])) return $attr; |
|
| 11 | + if ($config->get('HTML.Attr.Name.UseCDATA')) { |
|
| 12 | + return $attr; |
|
| 13 | + } |
|
| 14 | + if (!isset($attr['name'])) { |
|
| 15 | + return $attr; |
|
| 16 | + } |
|
| 13 | 17 | $id = $this->confiscateAttr($attr, 'name'); |
| 14 | - if ( isset($attr['id'])) return $attr; |
|
| 18 | + if ( isset($attr['id'])) { |
|
| 19 | + return $attr; |
|
| 20 | + } |
|
| 15 | 21 | $attr['id'] = $id; |
| 16 | 22 | return $attr; |
| 17 | 23 | } |
@@ -8,19 +8,19 @@ |
||
| 8 | 8 | class HTMLPurifier_AttrTransform_NameSync extends HTMLPurifier_AttrTransform |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - public function __construct() { |
|
| 12 | - $this->idDef = new HTMLPurifier_AttrDef_HTML_ID(); |
|
| 13 | - } |
|
| 11 | + public function __construct() { |
|
| 12 | + $this->idDef = new HTMLPurifier_AttrDef_HTML_ID(); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function transform($attr, $config, $context) { |
|
| 16 | - if (!isset($attr['name'])) return $attr; |
|
| 17 | - $name = $attr['name']; |
|
| 18 | - if (isset($attr['id']) && $attr['id'] === $name) return $attr; |
|
| 19 | - $result = $this->idDef->validate($name, $config, $context); |
|
| 20 | - if ($result === false) unset($attr['name']); |
|
| 21 | - else $attr['name'] = $result; |
|
| 22 | - return $attr; |
|
| 23 | - } |
|
| 15 | + public function transform($attr, $config, $context) { |
|
| 16 | + if (!isset($attr['name'])) return $attr; |
|
| 17 | + $name = $attr['name']; |
|
| 18 | + if (isset($attr['id']) && $attr['id'] === $name) return $attr; |
|
| 19 | + $result = $this->idDef->validate($name, $config, $context); |
|
| 20 | + if ($result === false) unset($attr['name']); |
|
| 21 | + else $attr['name'] = $result; |
|
| 22 | + return $attr; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -13,12 +13,19 @@ |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function transform($attr, $config, $context) { |
| 16 | - if (!isset($attr['name'])) return $attr; |
|
| 16 | + if (!isset($attr['name'])) { |
|
| 17 | + return $attr; |
|
| 18 | + } |
|
| 17 | 19 | $name = $attr['name']; |
| 18 | - if (isset($attr['id']) && $attr['id'] === $name) return $attr; |
|
| 20 | + if (isset($attr['id']) && $attr['id'] === $name) { |
|
| 21 | + return $attr; |
|
| 22 | + } |
|
| 19 | 23 | $result = $this->idDef->validate($name, $config, $context); |
| 20 | - if ($result === false) unset($attr['name']); |
|
| 21 | - else $attr['name'] = $result; |
|
| 24 | + if ($result === false) { |
|
| 25 | + unset($attr['name']); |
|
| 26 | + } else { |
|
| 27 | + $attr['name'] = $result; |
|
| 28 | + } |
|
| 22 | 29 | return $attr; |
| 23 | 30 | } |
| 24 | 31 | |
@@ -8,37 +8,37 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class HTMLPurifier_AttrTransform_Nofollow extends HTMLPurifier_AttrTransform |
| 10 | 10 | { |
| 11 | - private $parser; |
|
| 11 | + private $parser; |
|
| 12 | 12 | |
| 13 | - public function __construct() { |
|
| 14 | - $this->parser = new HTMLPurifier_URIParser(); |
|
| 15 | - } |
|
| 13 | + public function __construct() { |
|
| 14 | + $this->parser = new HTMLPurifier_URIParser(); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function transform($attr, $config, $context) { |
|
| 17 | + public function transform($attr, $config, $context) { |
|
| 18 | 18 | |
| 19 | - if (!isset($attr['href'])) { |
|
| 20 | - return $attr; |
|
| 21 | - } |
|
| 19 | + if (!isset($attr['href'])) { |
|
| 20 | + return $attr; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - // XXX Kind of inefficient |
|
| 24 | - $url = $this->parser->parse($attr['href']); |
|
| 25 | - $scheme = $url->getSchemeObj($config, $context); |
|
| 23 | + // XXX Kind of inefficient |
|
| 24 | + $url = $this->parser->parse($attr['href']); |
|
| 25 | + $scheme = $url->getSchemeObj($config, $context); |
|
| 26 | 26 | |
| 27 | - if ($scheme->browsable && !$url->isLocal($config, $context)) { |
|
| 28 | - if (isset($attr['rel'])) { |
|
| 29 | - $rels = explode(' ', $attr); |
|
| 30 | - if (!in_array('nofollow', $rels)) { |
|
| 31 | - $rels[] = 'nofollow'; |
|
| 32 | - } |
|
| 33 | - $attr['rel'] = implode(' ', $rels); |
|
| 34 | - } else { |
|
| 35 | - $attr['rel'] = 'nofollow'; |
|
| 36 | - } |
|
| 37 | - } |
|
| 27 | + if ($scheme->browsable && !$url->isLocal($config, $context)) { |
|
| 28 | + if (isset($attr['rel'])) { |
|
| 29 | + $rels = explode(' ', $attr); |
|
| 30 | + if (!in_array('nofollow', $rels)) { |
|
| 31 | + $rels[] = 'nofollow'; |
|
| 32 | + } |
|
| 33 | + $attr['rel'] = implode(' ', $rels); |
|
| 34 | + } else { |
|
| 35 | + $attr['rel'] = 'nofollow'; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return $attr; |
|
| 39 | + return $attr; |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -2,14 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | class HTMLPurifier_AttrTransform_SafeEmbed extends HTMLPurifier_AttrTransform |
| 4 | 4 | { |
| 5 | - public $name = "SafeEmbed"; |
|
| 5 | + public $name = "SafeEmbed"; |
|
| 6 | 6 | |
| 7 | - public function transform($attr, $config, $context) { |
|
| 8 | - $attr['allowscriptaccess'] = 'never'; |
|
| 9 | - $attr['allownetworking'] = 'internal'; |
|
| 10 | - $attr['type'] = 'application/x-shockwave-flash'; |
|
| 11 | - return $attr; |
|
| 12 | - } |
|
| 7 | + public function transform($attr, $config, $context) { |
|
| 8 | + $attr['allowscriptaccess'] = 'never'; |
|
| 9 | + $attr['allownetworking'] = 'internal'; |
|
| 10 | + $attr['type'] = 'application/x-shockwave-flash'; |
|
| 11 | + return $attr; |
|
| 12 | + } |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | // vim: et sw=4 sts=4 |