aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/league/html-to-markdown/src/Converter/LinkConverter.php')
-rw-r--r--vendor/league/html-to-markdown/src/Converter/LinkConverter.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/vendor/league/html-to-markdown/src/Converter/LinkConverter.php b/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
index 74b49a778..c82b70e97 100644
--- a/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
+++ b/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
@@ -21,6 +21,8 @@ class LinkConverter implements ConverterInterface
$markdown = '[' . $text . '](' . $href . ' "' . $title . '")';
} elseif ($href === $text && $this->isValidAutolink($href)) {
$markdown = '<' . $href . '>';
+ } elseif ($href === 'mailto:' . $text && $this->isValidEmail($text)) {
+ $markdown = '<' . $text . '>';
} else {
$markdown = '[' . $text . '](' . $href . ')';
}
@@ -49,4 +51,15 @@ class LinkConverter implements ConverterInterface
{
return preg_match('/^[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\x00-\x20]*/i', $href) === 1;
}
+
+ /**
+ * @param string $email
+ *
+ * @return bool
+ */
+ private function isValidEmail($email)
+ {
+ // Email validation is messy business, but this should cover most cases
+ return filter_var($email, FILTER_VALIDATE_EMAIL);
+ }
}