Просмотр исходного кода

Experiment with forcing HTTPS for selected embed providers

YouTube, DailyMotion, Tumblr
https://github.com/FreshRSS/FreshRSS/issues/1083
Alexandre Alapetite 10 лет назад
Родитель
Сommit
83e58d3759
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      lib/SimplePie/SimplePie/Misc.php

+ 10 - 1
lib/SimplePie/SimplePie/Misc.php

@@ -77,6 +77,15 @@ class SimplePie_Misc
 		return $time;
 		return $time;
 	}
 	}
 
 
+	/**
+	 * Force HTTPS for selected Web sites
+	 * FreshRSS
+	 */
+	public static https_url($url)
+	{
+		return preg_replace('%^http://((?:[^/]*?\.)?(?:youtube|dailymotion|tumblr)\.com/)%i', '//$1', $url);
+	}
+
 	public static function absolutize_url($relative, $base)
 	public static function absolutize_url($relative, $base)
 	{
 	{
 		if (substr($relative, 0, 2) === '//')
 		if (substr($relative, 0, 2) === '//')
@@ -88,7 +97,7 @@ class SimplePie_Misc
 		{
 		{
 			return false;
 			return false;
 		}
 		}
-		return $iri->get_uri();
+		return https_url($iri->get_uri());
 	}
 	}
 
 
 	/**
 	/**