Page MenuHomePhabricator

D8962.diff
No OneTemporary

D8962.diff

diff --git a/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php b/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php
--- a/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php
+++ b/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php
@@ -75,6 +75,7 @@
'uri.allowed-protocols',
array(
'http' => true,
+ 'mailto' => true,
));
$rules = array();
diff --git a/src/markup/engine/__tests__/remarkup/link-mailto.txt b/src/markup/engine/__tests__/remarkup/link-mailto.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/link-mailto.txt
@@ -0,0 +1,18 @@
+[[ mailto:alincoln@example.com | mail me ]]
+
+[ mail me ]( mailto:alincoln@example.com )
+
+[[mailto:alincoln@example.com]]
+
+~~~~~~~~~~
+<p><a href="mailto:alincoln@example.com" target="_blank" rel="noreferrer">mail me</a></p>
+
+<p><a href="mailto:alincoln@example.com" target="_blank" rel="noreferrer">mail me</a></p>
+
+<p><a href="mailto:alincoln@example.com" target="_blank" rel="noreferrer">alincoln@example.com</a></p>
+~~~~~~~~~~
+mail me <alincoln@example.com>
+
+mail me <alincoln@example.com>
+
+alincoln@example.com
diff --git a/src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleDocumentLink.php b/src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleDocumentLink.php
--- a/src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleDocumentLink.php
+++ b/src/markup/engine/remarkup/markuprule/PhutilRemarkupRuleDocumentLink.php
@@ -37,6 +37,10 @@
}
$text = $base.$text;
}
+
+ // If present, strip off "mailto:".
+ $text = preg_replace('/^mailto:/', '', $text);
+
if ($link == $name) {
return $text;
}
@@ -50,6 +54,8 @@
$target = null;
}
+ $name = preg_replace('/^mailto:/', '', $name);
+
if ($this->getEngine()->getState('toc')) {
return $name;
} else {
@@ -71,14 +77,15 @@
// discussion about C source code into a link. To this end, we:
//
// - Don't match at word boundaries;
- // - require the URI to contain a "/" character; and
+ // - require the URI to contain a "/" character or "@" character; and
// - reject URIs which being with a quote character.
if ($uri[0] == '"' || $uri[0] == "'" || $uri[0] == '`') {
return $matches[0];
}
- if (strpos($uri, '/') === false) {
+ if (strpos($uri, '/') === false &&
+ strpos($uri, '@') === false) {
return $matches[0];
}
@@ -95,8 +102,8 @@
$name = trim(idx($matches, 2, $uri));
// If whatever is being linked to begins with "/" or "#", or has "://",
- // treat it as a URI instead of a wiki page.
- $is_uri = preg_match('@(^/)|(://)|(^#)@', $uri);
+ // or is "mailto:", treat it as a URI instead of a wiki page.
+ $is_uri = preg_match('@(^/)|(://)|(^#)|(^mailto:)@', $uri);
if ($is_uri && strncmp('/', $uri, 1) && strncmp('#', $uri, 1)) {
$protocols = $this->getEngine()->getConfig(

File Metadata

Mime Type
text/plain
Expires
Fri, May 10, 6:37 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276011
Default Alt Text
D8962.diff (2 KB)

Event Timeline