0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/media/thumbnail: Add bypass for animated PNG thumbnailing.

This commit is contained in:
Jason Volk 2021-01-21 21:51:28 -08:00
parent ddfba500ad
commit 1d6325949d
2 changed files with 23 additions and 0 deletions

View file

@ -36,6 +36,7 @@ namespace ircd::m::media::thumbnail
{
extern conf::item<bool> enable;
extern conf::item<bool> enable_remote;
extern conf::item<bool> animation_enable;
extern conf::item<size_t> width_min;
extern conf::item<size_t> width_max;
extern conf::item<size_t> height_min;

View file

@ -27,6 +27,13 @@ ircd::m::media::thumbnail::enable_remote
{ "default", true },
};
decltype(ircd::m::media::thumbnail::animation_enable)
ircd::m::media::thumbnail::animation_enable
{
{ "name", "ircd.m.media.thumbnail.animation.enable" },
{ "default", true },
};
decltype(ircd::m::media::thumbnail::width_min)
ircd::m::media::thumbnail::width_min
{
@ -281,6 +288,18 @@ get__thumbnail_local(client &client,
&& (!mime_whitelist || has(mime_whitelist, mime_type))
};
const bool animated
{
// Administrator's fuse to disable animation detection.
bool(animation_enable)
// If the type is not permitted don't bother checking for animation.
&& permitted
// Case for APNG; do not permit them to be thumbnailed
&& (has(mime_type, "image/png") && png::is_animated(buf))
};
const bool valid_args
{
// Both dimension parameters given in query string
@ -301,6 +320,9 @@ get__thumbnail_local(client &client,
// Access denied for this operation
|| !permitted
// Bypassed to prevent loss of animation
|| animated
// Arguments invalid.
|| !valid_args
};