From 38a1b791749a9cd8142e820231f84c4aee67998e Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Mar 2023 20:59:36 +0000 Subject: fix max_oembed_size check if content length header is an array (e.g. after a redirect with code 301) - fix issue #1727 --- include/oembed.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/oembed.php') diff --git a/include/oembed.php b/include/oembed.php index bcf5d525c..fbe6a573b 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -147,6 +147,7 @@ function oembed_fetch_url($embedurl){ $txt = Cache::get('[' . App::$videowidth . '] ' . $furl); } + if(strpos(strtolower($embedurl),'.pdf') !== false && get_config('system','inline_pdf')) { $action = 'allow'; $j = [ @@ -158,7 +159,6 @@ function oembed_fetch_url($embedurl){ // set $txt to something so that we don't attempt to fetch what could be a lengthy pdf. $txt = EMPTY_STR; } - if(is_null($txt)) { $txt = EMPTY_STR; @@ -177,12 +177,17 @@ function oembed_fetch_url($embedurl){ $headers = get_headers($furl, true); - if (isset($headers['Content-Length']) && $headers['Content-Length'] > $max_oembed_size) { - $action = 'block'; + if (isset($headers['Content-Length'])) { + $content_length = ((is_array($headers['Content-Length'])) ? array_key_last($headers['Content-Length']) : $headers['Content-Length']); + + if ($content_length > $max_oembed_size) { + $action = 'block'; + } } } if ($action !== 'block') { + // try oembed autodiscovery $redirects = 0; $result = z_fetch_url($furl, false, $redirects, -- cgit v1.2.3