From 24de6d38a90a3e03bbac2a3d6ef6446492b72eac Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 27 Jul 2014 22:04:04 +0200 Subject: [PATCH] appnet/statusnet/twitter: Better detection for removable links. --- appnet/appnet.php | 8 ++------ statusnet/statusnet.php | 2 +- twitter/twitter.php | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/appnet/appnet.php b/appnet/appnet.php index db3422e4..3a6046b3 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -968,16 +968,12 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th if (sizeof($links)) { $link = array_pop($links); - $url = "[url=".$link."]".$link."[/url]"; - - $removedlink = trim(str_replace($url, "", $postarray['body'])); + $url = str_replace(array('/', '.'), array('\/', '\.'), $link); + $removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']); if (($removedlink == "") OR strstr($postarray['body'], $removedlink)) $postarray['body'] = $removedlink; - if (($removedlink == "") OR strstr("[url]".$postarray['body']."[/url]", $removedlink)) - $postarray['body'] = $removedlink; - $page_info = add_page_info($link, false, $photo["url"]); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 0cabbca8..b7ba8d7d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1538,7 +1538,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) { if (($footerlink != "") AND (trim($footer) != "")) { $removedlink = trim(str_replace($footerlink, "", $body)); - if (strstr($body, $removedlink)) + if (($removedlink == "") OR strstr($body, $removedlink)) $body = $removedlink; $body .= $footer; diff --git a/twitter/twitter.php b/twitter/twitter.php index 25c64b48..c961b6a9 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1142,7 +1142,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $picture) { if (($footerlink != "") AND (trim($footer) != "")) { $removedlink = trim(str_replace($footerlink, "", $body)); - if (strstr($body, $removedlink)) + if (($removedlink == "") OR strstr($body, $removedlink)) $body = $removedlink; $body .= $footer;