From fd8897851f9beab93d8ec3d0472937225c8f5118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 17 Jul 2018 22:28:20 +0200 Subject: [PATCH] Fixes for OEmbed class (#5392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes: - stdClass is clearly an object of `\stdClass`, so let's import it and set it as type-hint here - if $o->type is not found, don't continue Signed-off-by: Roland Häder * Fix for a fix due to 02:51 a.m. (!) edits ... Signed-off-by: Roland Häder --- src/Content/OEmbed.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 360a0dc48..390f3ea86 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -20,6 +20,7 @@ use DOMNode; use DOMText; use DOMXPath; use Exception; +use stdClass; require_once 'include/dba.php'; require_once 'mod/proxy.php'; @@ -163,11 +164,12 @@ class OEmbed return $j; } - private static function formatObject($j) + private static function formatObject(stdClass $j) { $embedurl = $j->embedurl; $jhtml = $j->html; $ret = '
'; + switch ($j->type) { case "video": if (isset($j->thumbnail_url)) { @@ -326,7 +328,7 @@ class OEmbed $o = self::fetchURL($url, !self::isAllowedURL($url)); - if (!is_object($o) || $o->type == 'error') { + if (!is_object($o) || property_exists($o, 'type') && $o->type == 'error') { throw new Exception('OEmbed failed for URL: ' . $url); }