media (e.g. video) files weren't being detected correctly in oembed, causing the stream to try and load large videos (and failing)

This commit is contained in:
redmatrix 2016-06-25 04:09:07 -07:00
parent c809b6f95e
commit f66576f366

View File

@ -27,12 +27,6 @@ function oembed_action($embedurl) {
logger('oembed_action: ' . $embedurl, LOGGER_DEBUG, LOG_INFO); logger('oembed_action: ' . $embedurl, LOGGER_DEBUG, LOG_INFO);
// These media files should now be caught in bbcode.php
// left here as a fallback in case this is called from another source
$noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm","opus");
$ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION);
if(strpos($embedurl,'http://') === 0) { if(strpos($embedurl,'http://') === 0) {
if(intval(get_config('system','embed_sslonly'))) { if(intval(get_config('system','embed_sslonly'))) {
$action = 'block'; $action = 'block';
@ -121,14 +115,19 @@ function oembed_fetch_url($embedurl){
// These media files should now be caught in bbcode.php // These media files should now be caught in bbcode.php
// left here as a fallback in case this is called from another source // left here as a fallback in case this is called from another source
$noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm","opus"); $noexts = array(".mp3",".mp4",".ogg",".ogv",".oga",".ogm",".webm",".opus");
$ext = pathinfo(strtolower($embedurl),PATHINFO_EXTENSION);
$result = oembed_action($embedurl); $result = oembed_action($embedurl);
$embedurl = $result['url']; $embedurl = $result['url'];
$action = $result['action']; $action = $result['action'];
foreach($noexts as $ext) {
if(strpos(strtolower($embedurl),$ext) !== false) {
$action = 'block';
}
}
$txt = null; $txt = null;
if($action !== 'block') { if($action !== 'block') {
@ -153,7 +152,7 @@ function oembed_fetch_url($embedurl){
} }
if (! in_array($ext, $noexts) && $action !== 'block') { if ($action !== 'block') {
// try oembed autodiscovery // try oembed autodiscovery
$redirects = 0; $redirects = 0;
$result = z_fetch_url($furl, false, $redirects, array('timeout' => 15, 'accept_content' => "text/*", 'novalidate' => true )); $result = z_fetch_url($furl, false, $redirects, array('timeout' => 15, 'accept_content' => "text/*", 'novalidate' => true ));