From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Mon, 8 Feb 2021 07:06:24 +0000 (-0500)
Subject: Move HTTPS exception for YouTube and Vimeo to OEmbed::fetchUrl
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4a57ed1a31eb96d55f70aaa6ed7ed7d8e6acc362;p=friendica.git

Move HTTPS exception for YouTube and Vimeo to OEmbed::fetchUrl

- Both Youtube and Vimeo output OEmbed endpoint URL with HTTP but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
---

diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php
index 3afa36904a..1a5d1d9042 100644
--- a/src/Content/OEmbed.php
+++ b/src/Content/OEmbed.php
@@ -106,6 +106,10 @@ class OEmbed
 							as $link)
 						{
 							$href = $link->getAttributeNode('href')->nodeValue;
+							// Both Youtube and Vimeo output OEmbed endpoint URL with HTTP
+							// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
+							$href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'],
+								['https://www.youtube.com/', 'https://player.vimeo.com/'], $href);
 							$result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->videowidth);
 							if ($result->getReturnCode() === 200) {
 								$json_string = $result->getBody();
@@ -335,10 +339,6 @@ class OEmbed
 
 	public static function getHTML($url, $title = null)
 	{
-		// Always embed the SSL version
-		$url = str_replace(["http://www.youtube.com/", "http://player.vimeo.com/"],
-					["https://www.youtube.com/", "https://player.vimeo.com/"], $url);
-
 		$o = self::fetchURL($url, !self::isAllowedURL($url));
 
 		if (!is_object($o) || property_exists($o, 'type') && $o->type == 'error') {