]> git.mxchange.org Git - friendica.git/blobdiff - mod/share.php
Merge branch 'develop' into rewrite/gravity-constants
[friendica.git] / mod / share.php
index 09097f070f3c6738200ebee43d6043d441a58f0d..de0159df78a83a980a9ed7dc668f6037e09f2d8f 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -40,13 +41,11 @@ function share_init(App $a) {
                System::exit();
        }
 
-       if (strpos($item['body'], "[/share]") !== false) {
-               $pos = strpos($item['body'], "[share");
-               $o = substr($item['body'], $pos);
+       $shared = BBCode::fetchShareAttributes($item['body']);
+       if (empty($shared['comment']) && (!empty($shared['message_id']) || !empty($shared['link']))) {
+               $content = '[share]' . ($shared['message_id'] ?: $shared['link']) . '[/share]';
        } else {
-               $o = "[share message_id='" . $item['uri'] . "'][/share]";
+               $content = '[share]' . $item['uri'] . '[/share]';
        }
-
-       echo $o;
-       System::exit();
+       System::httpExit($content);
 }