diff --git a/Parsedown.php b/Parsedown.php index 0dbf40c..c540d12 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -1422,7 +1422,10 @@ class Parsedown protected function element(array $Element) { - $Element = $this->sanitiseElement($Element); + if ($this->safeMode) + { + $Element = $this->sanitiseElement($Element); + } $markup = '<'.$Element['name']; @@ -1543,27 +1546,23 @@ class Parsedown protected function filterUnsafeUrlInAttribute(array $Element, $attribute) { - if ($this->safeMode) + foreach ($this->safeLinksWhitelist as $scheme) { - foreach ($this->safeLinksWhitelist as $scheme) + if (self::striAtStart($Element['attributes'][$attribute], $scheme)) { - if (self::striAtStart($Element['attributes'][$attribute], $scheme)) - { - return $Element; - } + return $Element; } - - $Element['attributes'][$attribute] = preg_replace_callback( - '/[^\/#?&=%]++/', - function (array $match) - { - return urlencode($match[0]); - }, - $Element['attributes'][$attribute] - ); - } + $Element['attributes'][$attribute] = preg_replace_callback( + '/[^\/#?&=%]++/', + function (array $match) + { + return urlencode($match[0]); + }, + $Element['attributes'][$attribute] + ); + return $Element; }