]> git.mxchange.org Git - friendica.git/commitdiff
Possibly handle issue 7772
authorMichael <heluecht@pirati.ca>
Sun, 27 Oct 2019 18:36:04 +0000 (18:36 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 27 Oct 2019 18:36:04 +0000 (18:36 +0000)
src/Content/Text/BBCode.php

index 9169c91d077a5cb70e2fa4211f5a767cf4df8663..c3ad23941d879213f1b36a685bacb9115d187811 100644 (file)
@@ -573,17 +573,17 @@ class BBCode extends BaseObject
         * Note: Can produce a [bookmark] tag in the returned string
         *
         * @brief Processes [attachment] tags
-        * @param string   $return
+        * @param string   $text
         * @param bool|int $simplehtml
         * @param bool     $tryoembed
         * @return string
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       private static function convertAttachment($return, $simplehtml = false, $tryoembed = true)
+       private static function convertAttachment($text, $simplehtml = false, $tryoembed = true)
        {
-               $data = self::getAttachmentData($return);
+               $data = self::getAttachmentData($text);
                if (empty($data) || empty($data['url'])) {
-                       return $return;
+                       return $text;
                }
 
                if (isset($data['title'])) {
@@ -600,7 +600,10 @@ class BBCode extends BaseObject
 
                $return = '';
                if (in_array($simplehtml, [7, 9])) {
-                       $return = self::convertUrlForActivityPub($data['url']);
+                       // Only add the link when it isn't already part of the body
+                       if (substr_count($text, $data['url']) == 1) {
+                               $return = self::convertUrlForActivityPub($data['url']);
+                       }
                } elseif (($simplehtml != 4) && ($simplehtml != 0)) {
                        $return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data['url'], $data['title']);
                } else {