diff --git a/PluralKit.Bot/Utils/AvatarUtils.cs b/PluralKit.Bot/Utils/AvatarUtils.cs index 24dee2a4..6bad7f7c 100644 --- a/PluralKit.Bot/Utils/AvatarUtils.cs +++ b/PluralKit.Bot/Utils/AvatarUtils.cs @@ -36,8 +36,6 @@ namespace PluralKit.Bot { throw Errors.AvatarServerError(response.StatusCode); if (response.Content.Headers.ContentLength == null) // Check presence of content length throw Errors.AvatarNotAnImage(null); - if (response.Content.Headers.ContentLength > Limits.AvatarFileSizeLimit) // Check content length - throw Errors.AvatarFileSizeLimit(response.Content.Headers.ContentLength.Value); if (!acceptableMimeTypes.Contains(response.Content.Headers.ContentType.MediaType)) // Check MIME type throw Errors.AvatarNotAnImage(response.Content.Headers.ContentType.MediaType); @@ -45,6 +43,9 @@ namespace PluralKit.Bot { // no need to do size checking on banners return; + if (response.Content.Headers.ContentLength > Limits.AvatarFileSizeLimit) // Check content length + throw Errors.AvatarFileSizeLimit(response.Content.Headers.ContentLength.Value); + // Parse the image header in a worker var stream = await response.Content.ReadAsStreamAsync(); var image = await Task.Run(() => Image.Identify(stream));