mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02: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]))
|
||||||
|
Loading…
Reference in New Issue
Block a user