From: Hypolite Petovan Date: Sat, 6 Jan 2018 05:35:43 +0000 (-0500) Subject: Replace hacky oembed local iframe with remote iframe html X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9593cac2d15dbf2530b67898fb88bef2b167eeab;p=friendica.git Replace hacky oembed local iframe with remote iframe html - Remove call to OEmbed::iframe - Replace oembed span by div - Replace double quotes with single --- diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index c317483d96..0095d2b3cb 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -160,8 +160,8 @@ class OEmbed public static function formatObject($j) { $embedurl = $j->embedurl; - $jhtml = self::iframe($j->embedurl, (isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null)); - $ret = ""; + $jhtml = $j->html; + $ret = '
'; switch ($j->type) { case "video": if (isset($j->thumbnail_url)) { @@ -173,7 +173,7 @@ class OEmbed $th = 120; $tw = $th * $tr; $tpl = get_markup_template('oembed_video.tpl'); - $ret.=replace_macros($tpl, array( + $ret .= replace_macros($tpl, array( '$baseurl' => System::baseUrl(), '$embedurl' => $embedurl, '$escapedhtml' => base64_encode($jhtml), @@ -184,33 +184,32 @@ class OEmbed } else { $ret = $jhtml; } - //$ret.="
"; break; case "photo": - $ret.= ""; + $ret .= ''; break; case "link": break; case "rich": - // not so safe.. if (self::isAllowedURL($embedurl)) { $ret .= proxy_parse_html($jhtml); } break; } + $ret .= '
'; // add link to source if not present in "rich" type if ($j->type != 'rich' || !strpos($j->html, $embedurl)) { - $ret .= "

"; + $ret .= '

'; if (isset($j->title)) { if (isset($j->provider_name)) { $ret .= $j->provider_name . ": "; } $embedlink = (isset($j->title)) ? $j->title : $embedurl; - $ret .= "$embedlink"; + $ret .= '' . $embedlink . ''; if (isset($j->author_name)) { - $ret.=" (" . $j->author_name . ")"; + $ret .= ' (' . $j->author_name . ')'; } } elseif (isset($j->provider_name) || isset($j->author_name)) { $embedlink = ""; @@ -229,16 +228,14 @@ class OEmbed $embedlink = $embedurl; } - $ret .= "$embedlink"; + $ret .= '' . $embedlink . ''; } - //if (isset($j->author_name)) $ret.=" by ".$j->author_name; - //if (isset($j->provider_name)) $ret.=" on ".$j->provider_name; $ret .= "

"; - } else { + } elseif (!strpos($j->html, $embedurl)) { // add for html2bbcode conversion - $ret .= "$embedurl"; + $ret .= '' . $j->title . ''; } - $ret.="
"; + $ret = str_replace("\n", "", $ret); return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret)); } @@ -272,7 +269,7 @@ class OEmbed $xpath = new DOMXPath($dom); $xattr = self::buildXPath("class", "oembed"); - $entries = $xpath->query("//span[$xattr]"); + $entries = $xpath->query("//div[$xattr]"); $xattr = "@rel='oembed'"; //oe_build_xpath("rel","oembed"); foreach ($entries as $e) { @@ -299,6 +296,8 @@ class OEmbed * Since the iframe is automatically resized on load, there are no need for ugly * and impractical scrollbars. * + * @todo This function is currently unused until someone™ adds support for a separate OEmbed domain + * * @param string $src Original remote URL to embed * @param string $width * @param string $height @@ -315,10 +314,7 @@ class OEmbed } $width = '100%'; - // Only proxy OEmbed URLs to avoid mixed-content errors - if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL && parse_url($src, PHP_URL_SCHEME) !== 'https') { - $src = System::baseUrl() . '/oembed/' . base64url_encode($src); - } + $src = System::baseUrl() . '/oembed/' . base64url_encode($src); return ''; }