From 9593cac2d15dbf2530b67898fb88bef2b167eeab Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 6 Jan 2018 00:35:43 -0500 Subject: [PATCH 1/4] Replace hacky oembed local iframe with remote iframe html - Remove call to OEmbed::iframe - Replace oembed span by div - Replace double quotes with single --- src/Content/OEmbed.php | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) 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 ''; } From 9e54d8d4b4c7369eec3860de9b586bba7539aa7c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 6 Jan 2018 00:39:59 -0500 Subject: [PATCH 2/4] Fix Twitter quote tweet display - Transforms twitter share tags into rich OEmbed attachments --- include/bbcode.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 87a8eaa9b3..3e82f90a16 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -76,7 +76,7 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { $oembed = $bookmark[0]; } - if (strstr(strtolower($oembed), "