[PLUGIN][Embed] Make it work when content-length header is not provided

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-02 21:23:16 +00:00
parent bfec10fc95
commit 2445b5318d
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -160,7 +160,7 @@ class Embed extends Plugin
fn () => DB::findOneBy('attachment_embed', ['link_id' => $link->getId()]), fn () => DB::findOneBy('attachment_embed', ['link_id' => $link->getId()]),
); );
} catch (DuplicateFoundException $e) { } catch (DuplicateFoundException $e) {
Log::warning($e); Log::warning($e->getMessage());
return Event::next; return Event::next;
} catch (NotFoundException) { } 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."); 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? // 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'); $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."); 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; return false;
} }