diff --git a/Parsedown.php b/Parsedown.php index e9a8cbd..23f89fd 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -1135,7 +1135,7 @@ class Parsedown 'name' => 'a', 'text' => $matches[1], 'attributes' => array( - 'href' => 'mailto:'.$matches[1], + 'href' => $this->encodeEmailUrl('mailto:' . $matches[1]), ), ), ); @@ -1231,6 +1231,11 @@ class Parsedown $url = str_replace(array('&', '<'), array('&', '<'), $Link['url']); + if ("mailto:" === substr($url, 0, 7)) + { + $url = $this->encodeEmailUrl($url); + } + if ($Excerpt['text'][0] === '!') { $Element = array( @@ -1331,6 +1336,17 @@ class Parsedown return $markup; } + + private function encodeEmailUrl ($email) + { + $encoded = ''; + + for ($x = 0, $_length = strlen($email); $x < $_length; $x ++) { + $encoded .= '&#x' . bin2hex($email[$x]) . ';'; + } + return $encoded; + } + # # Multiton # diff --git a/test/data/email.html b/test/data/email.html index c40759c..cef6d07 100644 --- a/test/data/email.html +++ b/test/data/email.html @@ -1 +1 @@ -

my email is me@example.com

\ No newline at end of file +

my email is me@example.com

\ No newline at end of file