From 822b3865df04bc89a3f177278807d284602ac856 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 13 Feb 2014 08:30:40 +0100 Subject: [PATCH] API: Better detection of repeated messages. Better handling of tags. (In a next step they will be included in the entities) --- include/api.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/include/api.php b/include/api.php index de0debf5a6..0e638779b5 100644 --- a/include/api.php +++ b/include/api.php @@ -1636,6 +1636,8 @@ $URLSearchString = "^\[\]"; + $bbcode = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'#$2',$bbcode); + $bbcode = preg_replace("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$bbcode); //$bbcode = preg_replace("/\[url\](.*?)\[\/url\]/ism",'[url=$1]$1[/url]',$bbcode); $bbcode = preg_replace("/\[video\](.*?)\[\/video\]/ism",'[url=$1]$1[/url]',$bbcode); @@ -1834,7 +1836,12 @@ // Retweets are only valid for top postings - if (($item['owner-link'] != $item['author-link']) AND ($item["id"] == $item["parent"])) { + // It doesn't work reliable with the link if its a feed + $IsRetweet = ($item['owner-link'] != $item['author-link']); + if ($IsRetweet) + $IsRetweet = (($item['owner-name'] != $item['author-name']) OR ($item['owner-avatar'] != $item['author-avatar'])); + + if ($IsRetweet AND ($item["id"] == $item["parent"])) { $retweeted_status = $status; $retweeted_status["user"] = api_get_user($a,$item["author-link"]); @@ -2385,8 +2392,12 @@ function api_get_nick($profile) { function api_clean_plain_items($Text) { $include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false"); - if ($include_entities == "true") - $Text = preg_replace("/\[url\=([^\]]*)\](.*?)\[\/url\]/ism",'[url=$1]$1[/url]',$Text); + if ($include_entities == "true") { + $URLSearchString = "^\[\]"; + + $Text = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'#$2',$Text); + $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",'[url=$1]$1[/url]',$Text); + } $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","api_cleanup_share",$Text); return($Text); -- 2.39.5