X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FText%2FBBCode.php;h=35f4979d11fe7ae943310e0d73b15488356ec857;hb=3e51a23bd50327b3a2a9fd5401ff504f6d2b1d08;hp=6c441bac6fb152621a948c8a98da59cee72b4020;hpb=a25c07b1627909eba4b0a463be53718b9eafd074;p=friendica.git diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 6c441bac6f..35f4979d11 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -359,6 +359,16 @@ class BBCode extends BaseObject return $naked_text; } + private static function proxyUrl($image, $simplehtml = false) + { + // Only send proxied pictures to API and for internal display + if (in_array($simplehtml, [false, 2])) { + return proxy_url($image); + } else { + return $image; + } + } + public static function scaleExternalImages($srctext, $include_link = true, $scale_replace = false) { // Suppress "view full size" @@ -562,13 +572,13 @@ class BBCode extends BaseObject } if ($data["image"] != "") { - $return .= sprintf('
', $data["url"], proxy_url($data["image"]), $data["title"]); + $return .= sprintf('
', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); } elseif ($data["preview"] != "") { - $return .= sprintf('
', $data["url"], proxy_url($data["preview"]), $data["title"]); + $return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); } if (($data["type"] == "photo") && ($data["url"] != "") && ($data["image"] != "")) { - $return .= sprintf('', $data["url"], proxy_url($data["image"]), $data["title"]); + $return .= sprintf('', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); } else { $return .= sprintf('

%s

', $data['url'], $data['title']); } @@ -839,7 +849,7 @@ class BBCode extends BaseObject // it loops over the array starting from the first element and going sequentially // to the last element $newbody = str_replace('[$#saved_image' . $cnt . '#$]', - '' . L10n::t('Image/photo') . '', $newbody); + '' . L10n::t('Image/photo') . '', $newbody); $cnt++; } @@ -1571,12 +1581,12 @@ class BBCode extends BaseObject // [img=widthxheight]image source[/img] $text = preg_replace_callback( "/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", - function ($matches) { + function ($matches) use ($simple_html) { if (strpos($matches[3], "data:image/") === 0) { return $matches[0]; } - $matches[3] = proxy_url($matches[3]); + $matches[3] = self::proxyUrl($matches[3], $simple_html); return "[img=" . $matches[1] . "x" . $matches[2] . "]" . $matches[3] . "[/img]"; }, $text @@ -1586,8 +1596,8 @@ class BBCode extends BaseObject $text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '', $text); $text = preg_replace_callback("/\[img\=([$URLSearchString]*)\](.*?)\[\/img\]/ism", - function ($matches) { - $matches[1] = proxy_url($matches[1]); + function ($matches) use ($simple_html) { + $matches[1] = self::proxyUrl($matches[1], $simple_html); $matches[2] = htmlspecialchars($matches[2], ENT_COMPAT); return '' . $matches[2] . ''; }, @@ -1597,12 +1607,12 @@ class BBCode extends BaseObject // [img]pathtoimage[/img] $text = preg_replace_callback( "/\[img\](.*?)\[\/img\]/ism", - function ($matches) { + function ($matches) use ($simple_html) { if (strpos($matches[1], "data:image/") === 0) { return $matches[0]; } - $matches[1] = proxy_url($matches[1]); + $matches[1] = self::proxyUrl($matches[1], $simple_html); return "[img]" . $matches[1] . "[/img]"; }, $text @@ -1623,15 +1633,15 @@ class BBCode extends BaseObject // Try to Oembed if ($try_oembed) { - $text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '', $text); - $text = preg_replace("/\[audio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3))\[\/audio\]/ism", '', $text); + $text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4).*?)\[\/video\]/ism", '', $text); + $text = preg_replace("/\[audio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3).*?)\[\/audio\]/ism", '', $text); $text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", $try_oembed_callback, $text); $text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", $try_oembed_callback, $text); } else { - $text = preg_replace("/\[video\](.*?)\[\/video\]/", + $text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '$1', $text); - $text = preg_replace("/\[audio\](.*?)\[\/audio\]/", + $text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '$1', $text); }