]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Bugfix for pull request #2147 (Fix for issue #2122)
[friendica.git] / include / bbcode.php
index 98c1f11991208e35ce0bcb4c94aad011dfd77c53..100c3b93061c9515f13df2c5a060cc31278b1512 100644 (file)
@@ -101,9 +101,13 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
 
                        if ($simplehtml == 7) {
                                $title2 = $title;
+
+                               $test1 = trim(html_entity_decode($match[1],ENT_QUOTES,'UTF-8'));
+                               $test2 = trim(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
+
                                // If the link description is similar to the text above then don't add the link description
-                               if (($title != "") AND ((strpos($match[1],$title) !== false) OR
-                                       (similar_text($match[1],$title) / strlen($title)) > 0.9))
+                               if (($title != "") AND ((strpos($test1,$test2) !== false) OR
+                                       (similar_text($test1,$test2) / strlen($title)) > 0.9))
                                        $title2 = $url;
                                $text = sprintf('<a href="%s" title="%s" class="attachment thumbnail" rel="nofollow external">%s</a><br />',
                                                $url, $title, $title2);
@@ -955,14 +959,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        $Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text);
 
        // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
-       if ($simplehtml != 7) {
+//     if ($simplehtml != 7) {
                if (!$forplaintext)
                        $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
                else {
                        $Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
                        $Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
                }
-       }
+//     }
 
        if ($tryoembed)
                $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text);