From ae6bd7dc1e87805447e765e08d7a31ae5ac03f32 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 7 Feb 2014 15:41:31 -0800 Subject: fix issue with double linkify in the git feed --- mod/item.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'mod') 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); /** -- cgit v1.2.3