Differential D20144 Diff 48100 src/markup/engine/remarkup/markuprule/PhutilRemarkupDocumentLinkRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/markup/engine/remarkup/markuprule/PhutilRemarkupDocumentLinkRule.php
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | return phutil_tag( | ||||
'rel' => 'noreferrer', | 'rel' => 'noreferrer', | ||||
), | ), | ||||
$name); | $name); | ||||
} | } | ||||
public function markupAlternateLink(array $matches) { | public function markupAlternateLink(array $matches) { | ||||
$uri = trim($matches[2]); | $uri = trim($matches[2]); | ||||
if (!strlen($uri)) { | |||||
return $matches[0]; | |||||
} | |||||
// NOTE: We apply some special rules to avoid false positives here. The | // NOTE: We apply some special rules to avoid false positives here. The | ||||
// major concern is that we do not want to convert `x[0][1](y)` in a | // major concern is that we do not want to convert `x[0][1](y)` in a | ||||
// discussion about C source code into a link. To this end, we: | // discussion about C source code into a link. To this end, we: | ||||
// | // | ||||
// - Don't match at word boundaries; | // - Don't match at word boundaries; | ||||
// - require the URI to contain a "/" character or "@" character; and | // - require the URI to contain a "/" character or "@" character; and | ||||
// - reject URIs which being with a quote character. | // - reject URIs which being with a quote character. | ||||
if ($uri[0] == '"' || $uri[0] == "'" || $uri[0] == '`') { | if ($uri[0] == '"' || $uri[0] == "'" || $uri[0] == '`') { | ||||
return $matches[0]; | return $matches[0]; | ||||
} | } | ||||
if (!strlen($uri[0])) { | |||||
return $matches[0]; | |||||
} | |||||
if (strpos($uri, '/') === false && | if (strpos($uri, '/') === false && | ||||
strpos($uri, '@') === false && | strpos($uri, '@') === false && | ||||
strncmp($uri, 'tel:', 4)) { | strncmp($uri, 'tel:', 4)) { | ||||
return $matches[0]; | return $matches[0]; | ||||
} | } | ||||
return $this->markupDocumentLink( | return $this->markupDocumentLink( | ||||
array( | array( | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |