diff --git a/wp-includes/functions-formatting.php b/wp-includes/functions-formatting.php
index 3b7b843f37..b6105c693e 100644
--- a/wp-includes/functions-formatting.php
+++ b/wp-includes/functions-formatting.php
@@ -589,12 +589,20 @@ function antispambot($emailaddy, $mailto=0) {
return $emailNOSPAMaddy;
}
-function make_clickable($ret) {
+function make_clickable_mine4($ret) {
$ret = ' ' . $ret;
- $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "$1$2", $ret);
- $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "$1$2", $ret);
- $ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([^,< \n\r]+)#i", "$1$2@$3", $ret);
- $ret = substr($ret, 1);
+ // in testing, using arrays here was found to be faster
+ $ret = preg_replace(
+ array(
+ '#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is',
+ '#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is',
+ '#([\s>])([a-z0-9\-_.]+)@([^,< \n\r]+)#i'),
+ array(
+ '$1$2',
+ '$1$2',
+ '$1$2@$3'),$ret);
+ // this one is not in an array because we need it to run last, for cleanup of accidental links within links
+ $ret = preg_replace("#(]+?>|>))]+?>([^>]+?)#i", "$1$3", $ret);
$ret = trim($ret);
return $ret;
}