Skip to content
Snippets Groups Projects
Commit d9e564d2 authored by Jared Hancock's avatar Jared Hancock
Browse files

Prepend `http://` to links starting with `www.`

parent 540f1bb0
Branches
Tags
No related merge requests found
...@@ -318,11 +318,14 @@ class Format { ...@@ -318,11 +318,14 @@ class Format {
.'|(\b[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})`', .'|(\b[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})`',
function ($match) use ($token) { function ($match) use ($token) {
if ($match[1]) { if ($match[1]) {
if (in_array(substr($match[1], -1), while (in_array(substr($match[1], -1),
array('.','?','-',':',';'))) { array('.','?','-',':',';'))) {
$match[9] = substr($match[1], -1); $match[9] = substr($match[1], -1) . $match[9];
$match[1] = substr($match[1], 0, strlen($match[1])-1); $match[1] = substr($match[1], 0, strlen($match[1])-1);
} }
if (strpos($match[2], '//') === false) {
$match[1] = 'http://' . $match[1];
}
return '<a href="l.php?url='.urlencode($match[1]) return '<a href="l.php?url='.urlencode($match[1])
.sprintf('&auth=%s" target="_blank">', $token) .sprintf('&auth=%s" target="_blank">', $token)
.$match[1].'</a>'.$match[9]; .$match[1].'</a>'.$match[9];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment