]> git.mxchange.org Git - friendica-addons.git/commitdiff
Fixed problems with images where the address contains special chars
authorMichael Vogel <icarus@dabo.de>
Sun, 8 Jul 2012 16:29:31 +0000 (18:29 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 8 Jul 2012 16:29:31 +0000 (18:29 +0200)
facebook/facebook.php
privacy_image_cache/privacy_image_cache.php
statusnet/statusnet.php
twitter/twitter.php

index 30f728628f0cb8786546752822d838d83a7c49a3..51f1fc846c424bd244230144c5ca10aca608e335 100644 (file)
@@ -1004,6 +1004,10 @@ function facebook_post_hook(&$a,&$b) {
                                        if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
                                                $image = $matches[1];
 
+                               // When saved into the database the content is sent through htmlspecialchars
+                               // That means that we have to decode all image-urls
+                               $image = htmlspecialchars_decode($image);
+
                                // Checking for a bookmark element
                                $body = $b['body'];
                                if (strpos($body, "[bookmark") !== false) {
@@ -1110,10 +1114,10 @@ function facebook_post_hook(&$a,&$b) {
                                                'access_token' => $fb_token,
                                                'message' => $msg
                                        );
-                                       if(isset($image)) {
+                                       if(trim($image) != "") {
                                                $postvars['picture'] = $image;
                                        }
-                                       if(isset($link)) {
+                                       if(trim($link) != "") {
                                                $postvars['link'] = $link;
 
                                                // The following doesn't work - why?
@@ -1121,7 +1125,7 @@ function facebook_post_hook(&$a,&$b) {
                                                        $postvars['source'] = $link;
                                                }
                                        }
-                                       if(isset($linkname))
+                                       if(trim($linkname) != "")
                                                $postvars['name'] = $linkname;
                                }
 
index b5cfb13e6d1c87319144a0ee2bb814e82f214bee..cd8a65f8b6c739c4d2b85453a8225d7915f98ee0 100644 (file)
@@ -127,7 +127,7 @@ function privacy_image_cache_img_cb($matches) {
        if (privacy_image_cache_is_local_image($matches[2]))
                return $matches[1] . $matches[2] . $matches[3];
 
-       return $matches[1] . get_app()->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($matches[2]))) . $matches[3];
+       return $matches[1] . get_app()->get_baseurl() . "/privacy_image_cache/?url=" . addslashes(rawurlencode(htmlspecialchars_decode($matches[2]))) . $matches[3];
 }
 
 /**
index b3a8a1a14e8534a48670c5d2347d4fbea3cea1c8..b433f57b2ae9ff6c3c7467662ca98ecd1b762859 100755 (executable)
@@ -503,10 +503,14 @@ function statusnet_post_hook(&$a,&$b) {
                         $msg = implode(' ', $e);
                        $msg .= '... ' . $shortlink;
                }
+
+               $msg = trim($msg);
+
                // and now dent it :-)
                if(strlen($msg)) {
                     $result = $dent->post('statuses/update', array('status' => $msg));
-                    logger('statusnet_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
+                    logger('statusnet_post send, result: ' . print_r($result, true).
+                           "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b));
                     if ($result->error) {
                         logger('Send to StatusNet failed: "' . $result->error . '"');
                     }
index 2849db968f8b1f1d41e5f2cbce1de9d913aef1e5..04c1c87df4e147526075f19ba39693780e76b4e2 100755 (executable)
@@ -367,6 +367,9 @@ function twitter_post_hook(&$a,&$b) {
                         $msg = implode(' ', $e);
                        $msg .= '... ' . $shortlink;
                }
+
+               $msg = trim($msg);
+
                // and now tweet it :-)
                if(strlen($msg)) {
                        $result = $tweet->post('statuses/update', array('status' => $msg));