aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mod/item.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/mod/item.php b/mod/item.php
index 47a3f1961..e8a58fe76 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -422,9 +422,15 @@ function item_post(&$a) {
/**
* fix naked links by passing through a callback to see if this is a red site
- * (already known to us) which will get a zrl, otherwise link with url
+ * (already known to us) which will get a zrl, otherwise link with url, add bookmark tag to both.
+ * First wrap any url which is part of link anchor text already in quotes so we don't double link it.
+ * e.g. [url=http://foobar.com]something with http://elsewhere.com in it[/url]
+ * becomes [url=http://foobar.com]something with "http://elsewhere.com" in it[/url]
+ * otherwise http://elsewhere.com becomes #^[url=http://elsewhere.com]http://elsewhere.com[/url]
*/
+ $body = preg_replace('/\[([uz])rl(.*?)\](.*?)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)(.*?)\[\/([uz])rl\]/ism','[$1rl$2]$3"$4"$5[/$6rl]',$body);
+
$body = preg_replace_callback("/([^\^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'red_zrl_callback', $body);
/**