@@ -7,32 +7,32 @@ |
||
| 7 | 7 | class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * IPv4 regex, protected so that IPv6 can reuse it |
|
| 12 | - */ |
|
| 13 | - protected $ip4; |
|
| 10 | + /** |
|
| 11 | + * IPv4 regex, protected so that IPv6 can reuse it |
|
| 12 | + */ |
|
| 13 | + protected $ip4; |
|
| 14 | 14 | |
| 15 | - public function validate($aIP, $config, $context) { |
|
| 15 | + public function validate($aIP, $config, $context) { |
|
| 16 | 16 | |
| 17 | - if (!$this->ip4) $this->_loadRegex(); |
|
| 17 | + if (!$this->ip4) $this->_loadRegex(); |
|
| 18 | 18 | |
| 19 | - if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) |
|
| 20 | - { |
|
| 21 | - return $aIP; |
|
| 22 | - } |
|
| 19 | + if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) |
|
| 20 | + { |
|
| 21 | + return $aIP; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - return false; |
|
| 24 | + return false; |
|
| 25 | 25 | |
| 26 | - } |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Lazy load function to prevent regex from being stuffed in |
|
| 30 | - * cache. |
|
| 31 | - */ |
|
| 32 | - protected function _loadRegex() { |
|
| 33 | - $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 |
|
| 34 | - $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * Lazy load function to prevent regex from being stuffed in |
|
| 30 | + * cache. |
|
| 31 | + */ |
|
| 32 | + protected function _loadRegex() { |
|
| 33 | + $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 |
|
| 34 | + $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
@@ -14,7 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function validate($aIP, $config, $context) { |
| 16 | 16 | |
| 17 | - if (!$this->ip4) $this->_loadRegex(); |
|
| 17 | + if (!$this->ip4) { |
|
| 18 | + $this->_loadRegex(); |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) |
| 20 | 22 | { |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | if (!$this->ip4) $this->_loadRegex(); |
| 18 | 18 | |
| 19 | - if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) |
|
| 19 | + if (preg_match('#^'.$this->ip4.'$#s', $aIP)) |
|
| 20 | 20 | { |
| 21 | 21 | return $aIP; |
| 22 | 22 | } |
@@ -17,39 +17,39 @@ |
||
| 17 | 17 | abstract class HTMLPurifier_AttrTransform |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Abstract: makes changes to the attributes dependent on multiple values. |
|
| 22 | - * |
|
| 23 | - * @param $attr Assoc array of attributes, usually from |
|
| 24 | - * HTMLPurifier_Token_Tag::$attr |
|
| 25 | - * @param $config Mandatory HTMLPurifier_Config object. |
|
| 26 | - * @param $context Mandatory HTMLPurifier_Context object |
|
| 27 | - * @returns Processed attribute array. |
|
| 28 | - */ |
|
| 29 | - abstract public function transform($attr, $config, $context); |
|
| 20 | + /** |
|
| 21 | + * Abstract: makes changes to the attributes dependent on multiple values. |
|
| 22 | + * |
|
| 23 | + * @param $attr Assoc array of attributes, usually from |
|
| 24 | + * HTMLPurifier_Token_Tag::$attr |
|
| 25 | + * @param $config Mandatory HTMLPurifier_Config object. |
|
| 26 | + * @param $context Mandatory HTMLPurifier_Context object |
|
| 27 | + * @returns Processed attribute array. |
|
| 28 | + */ |
|
| 29 | + abstract public function transform($attr, $config, $context); |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Prepends CSS properties to the style attribute, creating the |
|
| 33 | - * attribute if it doesn't exist. |
|
| 34 | - * @param $attr Attribute array to process (passed by reference) |
|
| 35 | - * @param $css CSS to prepend |
|
| 36 | - */ |
|
| 37 | - public function prependCSS(&$attr, $css) { |
|
| 38 | - $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; |
|
| 39 | - $attr['style'] = $css . $attr['style']; |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * Prepends CSS properties to the style attribute, creating the |
|
| 33 | + * attribute if it doesn't exist. |
|
| 34 | + * @param $attr Attribute array to process (passed by reference) |
|
| 35 | + * @param $css CSS to prepend |
|
| 36 | + */ |
|
| 37 | + public function prependCSS(&$attr, $css) { |
|
| 38 | + $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; |
|
| 39 | + $attr['style'] = $css . $attr['style']; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Retrieves and removes an attribute |
|
| 44 | - * @param $attr Attribute array to process (passed by reference) |
|
| 45 | - * @param $key Key of attribute to confiscate |
|
| 46 | - */ |
|
| 47 | - public function confiscateAttr(&$attr, $key) { |
|
| 48 | - if (!isset($attr[$key])) return null; |
|
| 49 | - $value = $attr[$key]; |
|
| 50 | - unset($attr[$key]); |
|
| 51 | - return $value; |
|
| 52 | - } |
|
| 42 | + /** |
|
| 43 | + * Retrieves and removes an attribute |
|
| 44 | + * @param $attr Attribute array to process (passed by reference) |
|
| 45 | + * @param $key Key of attribute to confiscate |
|
| 46 | + */ |
|
| 47 | + public function confiscateAttr(&$attr, $key) { |
|
| 48 | + if (!isset($attr[$key])) return null; |
|
| 49 | + $value = $attr[$key]; |
|
| 50 | + unset($attr[$key]); |
|
| 51 | + return $value; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | |
@@ -45,7 +45,9 @@ |
||
| 45 | 45 | * @param $key Key of attribute to confiscate |
| 46 | 46 | */ |
| 47 | 47 | public function confiscateAttr(&$attr, $key) { |
| 48 | - if (!isset($attr[$key])) return null; |
|
| 48 | + if (!isset($attr[$key])) { |
|
| 49 | + return null; |
|
| 50 | + } |
|
| 49 | 51 | $value = $attr[$key]; |
| 50 | 52 | unset($attr[$key]); |
| 51 | 53 | return $value; |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function prependCSS(&$attr, $css) { |
| 38 | 38 | $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; |
| 39 | - $attr['style'] = $css . $attr['style']; |
|
| 39 | + $attr['style'] = $css.$attr['style']; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -5,18 +5,18 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class HTMLPurifier_AttrTransform_Background extends HTMLPurifier_AttrTransform { |
| 7 | 7 | |
| 8 | - public function transform($attr, $config, $context) { |
|
| 8 | + public function transform($attr, $config, $context) { |
|
| 9 | 9 | |
| 10 | - if (!isset($attr['background'])) return $attr; |
|
| 10 | + if (!isset($attr['background'])) return $attr; |
|
| 11 | 11 | |
| 12 | - $background = $this->confiscateAttr($attr, 'background'); |
|
| 13 | - // some validation should happen here |
|
| 12 | + $background = $this->confiscateAttr($attr, 'background'); |
|
| 13 | + // some validation should happen here |
|
| 14 | 14 | |
| 15 | - $this->prependCSS($attr, "background-image:url($background);"); |
|
| 15 | + $this->prependCSS($attr, "background-image:url($background);"); |
|
| 16 | 16 | |
| 17 | - return $attr; |
|
| 17 | + return $attr; |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -7,7 +7,9 @@ |
||
| 7 | 7 | |
| 8 | 8 | public function transform($attr, $config, $context) { |
| 9 | 9 | |
| 10 | - if (!isset($attr['background'])) return $attr; |
|
| 10 | + if (!isset($attr['background'])) { |
|
| 11 | + return $attr; |
|
| 12 | + } |
|
| 11 | 13 | |
| 12 | 14 | $background = $this->confiscateAttr($attr, 'background'); |
| 13 | 15 | // some validation should happen here |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - public function transform($attr, $config, $context) { |
|
| 12 | - if (isset($attr['dir'])) return $attr; |
|
| 13 | - $attr['dir'] = $config->get('Attr.DefaultTextDir'); |
|
| 14 | - return $attr; |
|
| 15 | - } |
|
| 11 | + public function transform($attr, $config, $context) { |
|
| 12 | + if (isset($attr['dir'])) return $attr; |
|
| 13 | + $attr['dir'] = $config->get('Attr.DefaultTextDir'); |
|
| 14 | + return $attr; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
@@ -9,7 +9,9 @@ |
||
| 9 | 9 | { |
| 10 | 10 | |
| 11 | 11 | public function transform($attr, $config, $context) { |
| 12 | - if (isset($attr['dir'])) return $attr; |
|
| 12 | + if (isset($attr['dir'])) { |
|
| 13 | + return $attr; |
|
| 14 | + } |
|
| 13 | 15 | $attr['dir'] = $config->get('Attr.DefaultTextDir'); |
| 14 | 16 | return $attr; |
| 15 | 17 | } |
@@ -5,18 +5,18 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class HTMLPurifier_AttrTransform_BgColor extends HTMLPurifier_AttrTransform { |
| 7 | 7 | |
| 8 | - public function transform($attr, $config, $context) { |
|
| 8 | + public function transform($attr, $config, $context) { |
|
| 9 | 9 | |
| 10 | - if (!isset($attr['bgcolor'])) return $attr; |
|
| 10 | + if (!isset($attr['bgcolor'])) return $attr; |
|
| 11 | 11 | |
| 12 | - $bgcolor = $this->confiscateAttr($attr, 'bgcolor'); |
|
| 13 | - // some validation should happen here |
|
| 12 | + $bgcolor = $this->confiscateAttr($attr, 'bgcolor'); |
|
| 13 | + // some validation should happen here |
|
| 14 | 14 | |
| 15 | - $this->prependCSS($attr, "background-color:$bgcolor;"); |
|
| 15 | + $this->prependCSS($attr, "background-color:$bgcolor;"); |
|
| 16 | 16 | |
| 17 | - return $attr; |
|
| 17 | + return $attr; |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
@@ -7,7 +7,9 @@ |
||
| 7 | 7 | |
| 8 | 8 | public function transform($attr, $config, $context) { |
| 9 | 9 | |
| 10 | - if (!isset($attr['bgcolor'])) return $attr; |
|
| 10 | + if (!isset($attr['bgcolor'])) { |
|
| 11 | + return $attr; |
|
| 12 | + } |
|
| 11 | 13 | |
| 12 | 14 | $bgcolor = $this->confiscateAttr($attr, 'bgcolor'); |
| 13 | 15 | // some validation should happen here |
@@ -5,31 +5,31 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Name of boolean attribute that is trigger |
|
| 10 | - */ |
|
| 11 | - protected $attr; |
|
| 8 | + /** |
|
| 9 | + * Name of boolean attribute that is trigger |
|
| 10 | + */ |
|
| 11 | + protected $attr; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * CSS declarations to add to style, needs trailing semicolon |
|
| 15 | - */ |
|
| 16 | - protected $css; |
|
| 13 | + /** |
|
| 14 | + * CSS declarations to add to style, needs trailing semicolon |
|
| 15 | + */ |
|
| 16 | + protected $css; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @param $attr string attribute name to convert from |
|
| 20 | - * @param $css string CSS declarations to add to style (needs semicolon) |
|
| 21 | - */ |
|
| 22 | - public function __construct($attr, $css) { |
|
| 23 | - $this->attr = $attr; |
|
| 24 | - $this->css = $css; |
|
| 25 | - } |
|
| 18 | + /** |
|
| 19 | + * @param $attr string attribute name to convert from |
|
| 20 | + * @param $css string CSS declarations to add to style (needs semicolon) |
|
| 21 | + */ |
|
| 22 | + public function __construct($attr, $css) { |
|
| 23 | + $this->attr = $attr; |
|
| 24 | + $this->css = $css; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function transform($attr, $config, $context) { |
|
| 28 | - if (!isset($attr[$this->attr])) return $attr; |
|
| 29 | - unset($attr[$this->attr]); |
|
| 30 | - $this->prependCSS($attr, $this->css); |
|
| 31 | - return $attr; |
|
| 32 | - } |
|
| 27 | + public function transform($attr, $config, $context) { |
|
| 28 | + if (!isset($attr[$this->attr])) return $attr; |
|
| 29 | + unset($attr[$this->attr]); |
|
| 30 | + $this->prependCSS($attr, $this->css); |
|
| 31 | + return $attr; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
@@ -25,7 +25,9 @@ |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function transform($attr, $config, $context) { |
| 28 | - if (!isset($attr[$this->attr])) return $attr; |
|
| 28 | + if (!isset($attr[$this->attr])) { |
|
| 29 | + return $attr; |
|
| 30 | + } |
|
| 29 | 31 | unset($attr[$this->attr]); |
| 30 | 32 | $this->prependCSS($attr, $this->css); |
| 31 | 33 | return $attr; |
@@ -5,13 +5,13 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class HTMLPurifier_AttrTransform_Border extends HTMLPurifier_AttrTransform { |
| 7 | 7 | |
| 8 | - public function transform($attr, $config, $context) { |
|
| 9 | - if (!isset($attr['border'])) return $attr; |
|
| 10 | - $border_width = $this->confiscateAttr($attr, 'border'); |
|
| 11 | - // some validation should happen here |
|
| 12 | - $this->prependCSS($attr, "border:{$border_width}px solid;"); |
|
| 13 | - return $attr; |
|
| 14 | - } |
|
| 8 | + public function transform($attr, $config, $context) { |
|
| 9 | + if (!isset($attr['border'])) return $attr; |
|
| 10 | + $border_width = $this->confiscateAttr($attr, 'border'); |
|
| 11 | + // some validation should happen here |
|
| 12 | + $this->prependCSS($attr, "border:{$border_width}px solid;"); |
|
| 13 | + return $attr; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | } |
| 17 | 17 | |
@@ -6,7 +6,9 @@ |
||
| 6 | 6 | class HTMLPurifier_AttrTransform_Border extends HTMLPurifier_AttrTransform { |
| 7 | 7 | |
| 8 | 8 | public function transform($attr, $config, $context) { |
| 9 | - if (!isset($attr['border'])) return $attr; |
|
| 9 | + if (!isset($attr['border'])) { |
|
| 10 | + return $attr; |
|
| 11 | + } |
|
| 10 | 12 | $border_width = $this->confiscateAttr($attr, 'border'); |
| 11 | 13 | // some validation should happen here |
| 12 | 14 | $this->prependCSS($attr, "border:{$border_width}px solid;"); |
@@ -6,52 +6,52 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class HTMLPurifier_AttrTransform_EnumToCSS extends HTMLPurifier_AttrTransform { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Name of attribute to transform from |
|
| 11 | - */ |
|
| 12 | - protected $attr; |
|
| 9 | + /** |
|
| 10 | + * Name of attribute to transform from |
|
| 11 | + */ |
|
| 12 | + protected $attr; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Lookup array of attribute values to CSS |
|
| 16 | - */ |
|
| 17 | - protected $enumToCSS = array(); |
|
| 14 | + /** |
|
| 15 | + * Lookup array of attribute values to CSS |
|
| 16 | + */ |
|
| 17 | + protected $enumToCSS = array(); |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Case sensitivity of the matching |
|
| 21 | - * @warning Currently can only be guaranteed to work with ASCII |
|
| 22 | - * values. |
|
| 23 | - */ |
|
| 24 | - protected $caseSensitive = false; |
|
| 19 | + /** |
|
| 20 | + * Case sensitivity of the matching |
|
| 21 | + * @warning Currently can only be guaranteed to work with ASCII |
|
| 22 | + * values. |
|
| 23 | + */ |
|
| 24 | + protected $caseSensitive = false; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @param $attr String attribute name to transform from |
|
| 28 | - * @param $enumToCSS Lookup array of attribute values to CSS |
|
| 29 | - * @param $case_sensitive Boolean case sensitivity indicator, default false |
|
| 30 | - */ |
|
| 31 | - public function __construct($attr, $enum_to_css, $case_sensitive = false) { |
|
| 32 | - $this->attr = $attr; |
|
| 33 | - $this->enumToCSS = $enum_to_css; |
|
| 34 | - $this->caseSensitive = (bool) $case_sensitive; |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * @param $attr String attribute name to transform from |
|
| 28 | + * @param $enumToCSS Lookup array of attribute values to CSS |
|
| 29 | + * @param $case_sensitive Boolean case sensitivity indicator, default false |
|
| 30 | + */ |
|
| 31 | + public function __construct($attr, $enum_to_css, $case_sensitive = false) { |
|
| 32 | + $this->attr = $attr; |
|
| 33 | + $this->enumToCSS = $enum_to_css; |
|
| 34 | + $this->caseSensitive = (bool) $case_sensitive; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function transform($attr, $config, $context) { |
|
| 37 | + public function transform($attr, $config, $context) { |
|
| 38 | 38 | |
| 39 | - if (!isset($attr[$this->attr])) return $attr; |
|
| 39 | + if (!isset($attr[$this->attr])) return $attr; |
|
| 40 | 40 | |
| 41 | - $value = trim($attr[$this->attr]); |
|
| 42 | - unset($attr[$this->attr]); |
|
| 41 | + $value = trim($attr[$this->attr]); |
|
| 42 | + unset($attr[$this->attr]); |
|
| 43 | 43 | |
| 44 | - if (!$this->caseSensitive) $value = strtolower($value); |
|
| 44 | + if (!$this->caseSensitive) $value = strtolower($value); |
|
| 45 | 45 | |
| 46 | - if (!isset($this->enumToCSS[$value])) { |
|
| 47 | - return $attr; |
|
| 48 | - } |
|
| 46 | + if (!isset($this->enumToCSS[$value])) { |
|
| 47 | + return $attr; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $this->prependCSS($attr, $this->enumToCSS[$value]); |
|
| 50 | + $this->prependCSS($attr, $this->enumToCSS[$value]); |
|
| 51 | 51 | |
| 52 | - return $attr; |
|
| 52 | + return $attr; |
|
| 53 | 53 | |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | } |
| 57 | 57 | |
@@ -36,12 +36,16 @@ |
||
| 36 | 36 | |
| 37 | 37 | public function transform($attr, $config, $context) { |
| 38 | 38 | |
| 39 | - if (!isset($attr[$this->attr])) return $attr; |
|
| 39 | + if (!isset($attr[$this->attr])) { |
|
| 40 | + return $attr; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | $value = trim($attr[$this->attr]); |
| 42 | 44 | unset($attr[$this->attr]); |
| 43 | 45 | |
| 44 | - if (!$this->caseSensitive) $value = strtolower($value); |
|
| 46 | + if (!$this->caseSensitive) { |
|
| 47 | + $value = strtolower($value); |
|
| 48 | + } |
|
| 45 | 49 | |
| 46 | 50 | if (!isset($this->enumToCSS[$value])) { |
| 47 | 51 | return $attr; |
@@ -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 | } |