From 2b1bfbf52a457bdc05aace77505e8b6d4b8547c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Mon, 23 Jan 2017 23:28:56 +0100 Subject: [PATCH] Added a test for mailto: links --- libs/ContentTypes/Markdown/LinkRenderer.php | 2 +- tests/ContentTypes/Markdown/LinkRendererTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/ContentTypes/Markdown/LinkRenderer.php b/libs/ContentTypes/Markdown/LinkRenderer.php index d8d455d3..67b82c8a 100644 --- a/libs/ContentTypes/Markdown/LinkRenderer.php +++ b/libs/ContentTypes/Markdown/LinkRenderer.php @@ -65,7 +65,7 @@ protected function isValidUrl($url) protected function isExternalUrl($url) { - return preg_match('|^(?:[a-z]+:)?//|', $url) || substr($url, 0, 7) == "mailto:"; + return preg_match('#^(?:[a-z]+:)?//|^mailto:#', $url); } /** diff --git a/tests/ContentTypes/Markdown/LinkRendererTest.php b/tests/ContentTypes/Markdown/LinkRendererTest.php index af84842d..08a3dd86 100644 --- a/tests/ContentTypes/Markdown/LinkRendererTest.php +++ b/tests/ContentTypes/Markdown/LinkRendererTest.php @@ -51,6 +51,9 @@ public function providerRenderLink() // /Content/Page ['Link', '[Link](../Widgets/Button.md)', 'Content/Page.html'], ['Link', '[Link](!Widgets/Button)', 'Content/Page.html'], + + // Mailto links + ['me@mydomain.com', '[me@mydomain.com](mailto:me@mydomain.com)', 'Content/Page.html'], ]; }