From 01971428aa30aeef09dd46735da67c9e68fd6d3d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 11 Feb 2014 23:42:06 +0100 Subject: [PATCH 1/6] target="_blank" instead of target="external-link" --- include/bbcode.php | 45 +++++++++++++++------ include/conversation.php | 6 +-- include/text.php | 10 ++--- view/templates/event.tpl | 2 +- view/templates/events.tpl | 2 +- view/templates/profile_vcard.tpl | 2 +- view/templates/wall_thread.tpl | 2 +- view/theme/vier/templates/profile_vcard.tpl | 2 +- 8 files changed, 45 insertions(+), 26 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index ee066f05a..186caad7b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -322,7 +322,7 @@ function bb_ShareAttributes($match) { if ($avatar != "") $headline .= ''; - $headline .= sprintf(t('%s wrote the following post'.$reldate.':'), $profile, $author, $link); + $headline .= sprintf(t('%s wrote the following post'.$reldate.':'), $profile, $author, $link); $headline .= ""; @@ -369,7 +369,7 @@ function bb_ShareAttributesDiaspora($match) { $headline .= ''.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$userid.':'; //$headline .= sprintf(t(''. // html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'). - // '%s%s:'), $profile, $userid, $posted); + // '%s%s:'), $profile, $userid, $posted); $headline .= ""; $text = trim($match[1]); @@ -423,7 +423,7 @@ function bb_ShareAttributesForExport($match) { $headline = '
'; $headline .= sprintf(t(''. html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'). - '%s%s:'), $link, $userid, $posted); + '%s%s:'), $link, $userid, $posted); $headline .= "
"; $text = trim($match[1]); @@ -533,6 +533,23 @@ function GetProfileUsername($profile, $username) { return($username); } +function RemovePictureLinks($match) { + $ch = @curl_init($match[2]); + @curl_setopt($ch, CURLOPT_NOBODY, true); + @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)"); + @curl_exec($ch); + $curl_info = @curl_getinfo($ch); + + if (substr($curl_info["content_type"], 0, 6) == "image/") + $text = "[url=".$match[2]."]".$match[2]."[/url]"; + else + $text = "[url=".$match[1]."]".$match[1]."[/url]"; + + return($text); +} + + // BBcode 2 HTML was written by WAY2WEB.net // extended to work with Mistpark/Friendica - Mike Macgirvin @@ -632,19 +649,21 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text if (!$forplaintext) - $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1$2', $Text); - else - $Text = preg_replace("(\[url\](.*?)\[\/url\])ism"," $1 ",$Text); + $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1$2', $Text); + else { + $Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text); + $Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'RemovePictureLinks', $Text); + } if ($tryoembed) $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text); - $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '$1', $Text); - $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $Text); + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '$1', $Text); + $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $Text); //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '$2', $Text); // Red compatibility, though the link can't be authenticated on Friendica - $Text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '$2', $Text); + $Text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '$2', $Text); // we may need to restrict this further if it picks up too many strays @@ -812,9 +831,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", 'tryoembed', $Text); } else { $Text = preg_replace("/\[video\](.*?)\[\/video\]/", - '$1', $Text); + '$1', $Text); $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", - '$1', $Text); + '$1', $Text); } // html5 video and audio @@ -840,7 +859,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); else $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", - 'https://www.youtube.com/watch?v=$1', $Text); + 'https://www.youtube.com/watch?v=$1', $Text); if ($tryoembed) { $Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); @@ -854,7 +873,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); else $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", - 'https://vimeo.com/$1', $Text); + 'https://vimeo.com/$1', $Text); // $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '', $Text); diff --git a/include/conversation.php b/include/conversation.php index 5b9a11bde..8e868afec 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -558,13 +558,13 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $tag["url"] = $searchpath.strtolower($tag["term"]); if ($tag["type"] == TERM_HASHTAG) { - $hashtags[] = "#".$tag["term"].""; + $hashtags[] = "#".$tag["term"].""; $prefix = "#"; } elseif ($tag["type"] == TERM_MENTION) { - $mentions[] = "@".$tag["term"].""; + $mentions[] = "@".$tag["term"].""; $prefix = "@"; } - $tags[] = $prefix."".$tag["term"].""; + $tags[] = $prefix."".$tag["term"].""; } /*foreach(explode(',',$item['tag']) as $tag){ diff --git a/include/text.php b/include/text.php index a47e352ba..0638f9e24 100644 --- a/include/text.php +++ b/include/text.php @@ -964,7 +964,7 @@ if(! function_exists('linkify')) { * @param string $s */ function linkify($s) { - $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' $1', $s); + $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' $1', $s); $s = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$s); return($s); }} @@ -1297,13 +1297,13 @@ function prepare_body(&$item,$attach = false) { $tag["url"] = $searchpath.strtolower($tag["term"]); if ($tag["type"] == TERM_HASHTAG) { - $hashtags[] = "#".$tag["term"].""; + $hashtags[] = "#".$tag["term"].""; $prefix = "#"; } elseif ($tag["type"] == TERM_MENTION) { - $mentions[] = "@".$tag["term"].""; + $mentions[] = "@".$tag["term"].""; $prefix = "@"; } - $tags[] = $prefix."".$tag["term"].""; + $tags[] = $prefix."".$tag["term"].""; } } @@ -1414,7 +1414,7 @@ function prepare_body(&$item,$attach = false) { $title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1])); $title .= ' ' . $mtch[2] . ' ' . t('bytes'); - $as .= '' . $icon . ''; + $as .= '' . $icon . ''; } } } diff --git a/view/templates/event.tpl b/view/templates/event.tpl index 4788dcb38..961f0155b 100644 --- a/view/templates/event.tpl +++ b/view/templates/event.tpl @@ -8,7 +8,7 @@ {{if $event.item.author_name}}{{$event.item.author_name}}{{/if}} {{$event.html}} - {{if $event.item.plink}}{{/if}} + {{if $event.item.plink}}{{/if}} {{if $event.edit}}{{/if}}
diff --git a/view/templates/events.tpl b/view/templates/events.tpl index 054200ca2..f798a8e37 100644 --- a/view/templates/events.tpl +++ b/view/templates/events.tpl @@ -21,7 +21,7 @@ {{if $event.is_first}}
{{$event.d}}
{{/if}} {{if $event.item.author_name}}{{$event.item.author_name}}{{/if}} {{$event.html}} - {{if $event.item.plink}}{{/if}} + {{if $event.item.plink}}{{/if}} {{if $event.edit}}{{/if}}
diff --git a/view/templates/profile_vcard.tpl b/view/templates/profile_vcard.tpl index 3f4d3c711..4734f5525 100644 --- a/view/templates/profile_vcard.tpl +++ b/view/templates/profile_vcard.tpl @@ -34,7 +34,7 @@ {{if $marital}}
{{$marital}}
{{$profile.marital}}
{{/if}} - {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} + {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} {{include file="diaspora_vcard.tpl"}} diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index c0e30c4cb..6dc9e5c3a 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -75,7 +75,7 @@ {{/if}} {{if $item.plink}} - + {{/if}} {{if $item.edpost}} diff --git a/view/theme/vier/templates/profile_vcard.tpl b/view/theme/vier/templates/profile_vcard.tpl index 9e0da287c..0a5464252 100644 --- a/view/theme/vier/templates/profile_vcard.tpl +++ b/view/theme/vier/templates/profile_vcard.tpl @@ -52,7 +52,7 @@ {{if $marital}}
{{$marital}}
{{$profile.marital}}
{{/if}} - {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} + {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} {{include file="diaspora_vcard.tpl"}} From 66f4e09baa4139ab51e0a26e8facb6a6ee7da6f9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 11 Feb 2014 23:43:34 +0100 Subject: [PATCH 2/6] api: Improvements for entities --- include/api.php | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/include/api.php b/include/api.php index f1221ef0b..5b5b65798 100644 --- a/include/api.php +++ b/include/api.php @@ -1639,6 +1639,9 @@ // if (!$include_entities OR ($include_entities == "false")) // return false; + // Change pure links in text to bbcode uris + $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); + $entities = array(); $entities["hashtags"] = array(); $entities["symbols"] = array(); @@ -1648,8 +1651,15 @@ $bbcode = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/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); + + $bbcode = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", + '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode); $bbcode = preg_replace("/\[youtube\](.*?)\[\/youtube\]/ism",'[url=$1]$1[/url]',$bbcode); + + $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", + '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode); $bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode); + $bbcode = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $bbcode); $URLSearchString = "^\[\]"; @@ -1716,8 +1726,8 @@ $image = @imagecreatefromstring($img_str); if ($image) { $entities["media"][] = array( - "id" => $start, - "id_str" => (string)$start, + "id" => $start+1, + "id_str" => (string)$start+1, "indices" => array($start, $start+strlen($url)), "media_url" => $url, "media_url_https" => $url, @@ -1792,7 +1802,8 @@ // Workaround for ostatus messages where the title is identically to the body //$statusbody = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 5, true), 0)); - $statusbody = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 2, true), 0)); + $html = bbcode(api_clean_plain_items($item['body']), false, false, 2, true); + $statusbody = trim(html2plain($html, 0)); $statustitle = trim($item['title']); @@ -2390,20 +2401,20 @@ function api_clean_plain_items($Text) { } function api_cleanup_share($shared) { - if ($shared[2] != "type-link") - return($shared[3]); + if ($shared[2] != "type-link") + return($shared[0]); - if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark)) - return($shared[3]); + if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark)) + return($shared[0]); - $title = ""; - $link = ""; + $title = ""; + $link = ""; - if (isset($bookmark[2][0])) - $title = $bookmark[2][0]; + if (isset($bookmark[2][0])) + $title = $bookmark[2][0]; - if (isset($bookmark[1][0])) - $link = $bookmark[1][0]; + if (isset($bookmark[1][0])) + $link = $bookmark[1][0]; if (strpos($shared[1],$title) !== false) $title = ""; @@ -2411,16 +2422,16 @@ function api_cleanup_share($shared) { if (strpos($shared[1],$link) !== false) $link = ""; - $text = trim($shared[1]); + $text = trim($shared[1]); //if (strlen($text) < strlen($title)) if (($text == "") AND ($title != "")) $text .= "\n\n".trim($title); - if ($link != "") - $text .= "\n".trim($link); + if ($link != "") + $text .= "\n".trim($link); - return(trim($text)); + return(trim($text)); } function api_best_nickname(&$contacts) { From 8c1d31deccd4b0b8cabe4d4a29fcf777bdc7bab7 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 11 Feb 2014 23:44:45 +0100 Subject: [PATCH 3/6] Showing "view full size" is now configurable --- include/network.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/network.php b/include/network.php index a663a6d94..4bc50974b 100644 --- a/include/network.php +++ b/include/network.php @@ -826,6 +826,10 @@ function add_fcontact($arr,$update = false) { function scale_external_images($srctext, $include_link = true, $scale_replace = false) { + // Suppress "view full size" + if (intval(get_config('system','no_view_full_size'))) + $include_link = false; + $a = get_app(); // Picture addresses can contain special characters From 84bbb69c233b19b3442e31fd5928b1bec0ab042e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 12 Feb 2014 01:41:45 +0100 Subject: [PATCH 4/6] API: Support of "include_entities" --- include/api.php | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/include/api.php b/include/api.php index 5b5b65798..de0debf5a 100644 --- a/include/api.php +++ b/include/api.php @@ -952,8 +952,6 @@ $start = $page*$count; - //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $sql_extra = ''; if ($max_id > 0) $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); @@ -1031,8 +1029,6 @@ $start = $page*$count; - //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - if ($max_id > 0) $sql_extra = 'AND `item`.`id` <= '.intval($max_id); if ($exclude_replies > 0) @@ -1100,7 +1096,6 @@ logger('API: api_statuses_show: '.$id); - //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); $conversation = (x($_REQUEST,'conversation')?1:0); $sql_extra = ''; @@ -1169,8 +1164,6 @@ logger('API: api_conversation_show: '.$id); - //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $sql_extra = ''; if ($max_id > 0) @@ -1225,8 +1218,6 @@ logger('API: api_statuses_repeat: '.$id); - //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`nick` as `reply_author`, `contact`.`name`, `contact`.`photo` as `reply_photo`, `contact`.`url` as `reply_url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, @@ -1328,8 +1319,6 @@ $start = $page*$count; - //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - // Ugly code - should be changed $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname']; $myurl = substr($myurl,strpos($myurl,'://')+3); @@ -1626,18 +1615,15 @@ function api_get_entitities($text, $bbcode) { /* To-Do: - * remove links to pictures if they are links of a picture - * Some video stuff isn't recognized * Links at the first character of the post * different sizes of pictures * caching picture data (using the id for that?) (See privacy_image_cache) */ - $include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:true); + $include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false"); -// To-Do -// if (!$include_entities OR ($include_entities == "false")) -// return false; + if ($include_entities != "true") + return false; // Change pure links in text to bbcode uris $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); @@ -1648,7 +1634,9 @@ $entities["urls"] = array(); $entities["user_mentions"] = array(); - $bbcode = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'[url=$1]$2[/url]',$bbcode); + $URLSearchString = "^\[\]"; + + $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); @@ -1662,7 +1650,6 @@ $bbcode = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $bbcode); - $URLSearchString = "^\[\]"; //preg_match_all("/\[url\]([$URLSearchString]*)\[\/url\]/ism", $bbcode, $urls1); preg_match_all("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $bbcode, $urls); @@ -2396,6 +2383,11 @@ 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); + $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","api_cleanup_share",$Text); return($Text); } From 822b3865df04bc89a3f177278807d284602ac856 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 13 Feb 2014 08:30:40 +0100 Subject: [PATCH 5/6] 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 de0debf5a..0e638779b 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); From 35048819ff34f11bec841665ebd915f8d24ec6bf Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 13 Feb 2014 23:07:51 +0100 Subject: [PATCH 6/6] API: Retweets with Twidere now work again. --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index 0e638779b..b9187ca3a 100644 --- a/include/api.php +++ b/include/api.php @@ -1623,7 +1623,7 @@ $include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false"); if ($include_entities != "true") - return false; + return array(); // Change pure links in text to bbcode uris $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);