X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fbbcode.php;h=a6ffc39c18744c4dd999d994766aede3ae4c1841;hb=c4d3ab68785122ff070c65a444aaa0833b746b2b;hp=fed535db573b8c52609b3d7c0a756703555653ce;hpb=390d5706f46ce58cbed24b292d5c1f1b9789a8a8;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index fed535db57..a6ffc39c18 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -46,21 +46,21 @@ function bb_map_location($match) { * Note: Can produce a [bookmark] tag in the returned string * * @brief Processes [attachment] tags - * @param string $Text + * @param string $return * @param bool|int $simplehtml * @param bool $tryoembed * @return string */ -function bb_attachment($Text, $simplehtml = false, $tryoembed = true) +function bb_attachment($return, $simplehtml = false, $tryoembed = true) { - $data = get_attachment_data($Text); + $data = get_attachment_data($return); if (!$data) { - return $Text; + return $return; } if (isset($data["title"])) { $data["title"] = strip_tags($data["title"]); - $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]); + $data["title"] = str_replace(["http://", "https://"], "", $data["title"]); } if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && ($data["image"] != "")) { @@ -68,49 +68,50 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) $data["image"] = ""; } + $return = ''; if ($simplehtml == 7) { - $text = style_url_for_mastodon($data["url"]); + $return = style_url_for_mastodon($data["url"]); } elseif (($simplehtml != 4) && ($simplehtml != 0)) { - $text = sprintf('%s
', $data["url"], $data["title"]); + $return = sprintf('%s
', $data["url"], $data["title"]); } else { - if ($simplehtml != 4) { - $text = sprintf('', $data["type"]); - } - - $oembed = sprintf('[bookmark=%s]%s[/bookmark]', $data['url'], $data['title']); - if ($tryoembed) { - try { - $oembed = OEmbed::getHTML($data['url'], $data['title']); - } catch (Exception $e) { - // $oembed isn't modified + try { + if ($tryoembed && OEmbed::isAllowedURL($data['url'])) { + $return = OEmbed::getHTML($data['url'], $data['title']); + } else { + throw new Exception('OEmbed is disabled for this attachment.'); + } + } catch (Exception $e) { + if ($simplehtml != 4) { + $return = sprintf('
', $data["type"]); } - } - if (stripos($oembed, "