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:
parent
f70d96479a
commit
721b885dd3
@ -1142,8 +1142,14 @@ class Parsedown
|
|||||||
|
|
||||||
protected function inlineEmailTag($Excerpt)
|
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];
|
$url = $matches[1];
|
||||||
|
|
||||||
if ( ! isset($matches[2]))
|
if ( ! isset($matches[2]))
|
||||||
@ -1479,7 +1485,7 @@ class Parsedown
|
|||||||
{
|
{
|
||||||
$markup .= '>';
|
$markup .= '>';
|
||||||
|
|
||||||
if (!isset($Element['nonNestables']))
|
if (!isset($Element['nonNestables']))
|
||||||
{
|
{
|
||||||
$Element['nonNestables'] = array();
|
$Element['nonNestables'] = array();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user