]> git.mxchange.org Git - friendica-addons.git/commitdiff
appnet/statusnet/twitter: Better detection for removable links.
authorMichael Vogel <icarus@dabo.de>
Sun, 27 Jul 2014 20:04:04 +0000 (22:04 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 27 Jul 2014 20:04:04 +0000 (22:04 +0200)
appnet/appnet.php
statusnet/statusnet.php
twitter/twitter.php

index db3422e4612e20063816c7980ee77575ac5e44b9..3a6046b3646b91a741d7e5641569c15a3f3ea96e 100644 (file)
@@ -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"]);
        }
 
index 0cabbca8de2895c78d2b68693a01435b9c82db97..b7ba8d7d6363c6a2f3a6da9a1f640e85a3380c63 100644 (file)
@@ -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;
index 25c64b481a068655eafaa206e0d2cc1da6fe8ff0..c961b6a9955a337b997d1aee5f2fc9ffd11eaeb6 100644 (file)
@@ -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;