Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15401871
D8962.id21283.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8962.id21283.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 7:36 PM (1 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7389158
Default Alt Text
D8962.id21283.diff (2 KB)
Attached To
Mode
D8962: Add piles of special casing to support "mailto:"
Attached
Detach File
Event Timeline
Log In to Comment