From 2445b5318d46ae4926224295085f1c4ad0f20540 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Thu, 2 Dec 2021 21:23:16 +0000 Subject: [PATCH] [PLUGIN][Embed] Make it work when content-length header is not provided --- plugins/Embed/Embed.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/Embed/Embed.php b/plugins/Embed/Embed.php index d73c61734b..79a05d1751 100644 --- a/plugins/Embed/Embed.php +++ b/plugins/Embed/Embed.php @@ -160,7 +160,7 @@ class Embed extends Plugin fn () => DB::findOneBy('attachment_embed', ['link_id' => $link->getId()]), ); } catch (DuplicateFoundException $e) { - Log::warning($e); + Log::warning($e->getMessage()); return Event::next; } catch (NotFoundException) { Log::debug("Embed doesn't have a representation for the link id={$link->getId()}. Must have been stored before the plugin was enabled."); @@ -357,9 +357,9 @@ class Embed extends Plugin } // Does it respect the file quota? - $file_size = $headers['content-length'][0]; + $file_size = $headers['content-length'][0] ?? null; $max_size = Common::config('attachments', 'file_quota'); - if ($file_size > $max_size) { + if (is_null($file_size) || $file_size > $max_size) { Log::debug("Went to download remote thumbnail of size {$file_size} but the upload limit is {$max_size} so we aborted in Embed->downloadThumbnail."); return false; }