1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Fix #565 by validating email as defined in commonmark spec

This commit is contained in:
Aidan Woods 2018-03-09 16:49:04 +00:00
parent f70d96479a
commit 721b885dd3
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -1142,8 +1142,14 @@ class Parsedown
protected function inlineEmailTag($Excerpt)
{
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
{
$commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9]'
.'(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?'
.'(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*'
;
if (strpos($Excerpt['text'], '>') !== false
and preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches)
){
$url = $matches[1];
if ( ! isset($matches[2]))
@ -1479,7 +1485,7 @@ class Parsedown
{
$markup .= '>';
if (!isset($Element['nonNestables']))
if (!isset($Element['nonNestables']))
{
$Element['nonNestables'] = array();
}