summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authordevonh <devon.dmytro@gmail.com>2024-05-08 14:57:32 +0000
committerGitHub <noreply@github.com>2024-05-08 14:57:32 +0000
commit393429d6928ce5cef6ced647567b7ec899d69ecc (patch)
tree79be7c0918d5272296b4046f8549228837ecebba /synapse/handlers
parentOptional whitespace support in Authorization (#1350) (#17145) (diff)
downloadsynapse-393429d6928ce5cef6ced647567b7ec899d69ecc.tar.xz
Fix undiscovered linter errors (#17166)
Linter errors are showing up in #17147 that are unrelated to that PR.
The errors do not currently show up on develop.

This PR aims to resolve the linter errors separately from #17147.
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/profile.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index e51e282a9f..6663d4b271 100644
--- a/synapse/handlers/profile.py
+++ b/synapse/handlers/profile.py
@@ -20,7 +20,7 @@
 #
 import logging
 import random
-from typing import TYPE_CHECKING, Optional, Union
+from typing import TYPE_CHECKING, List, Optional, Union
 
 from synapse.api.errors import (
     AuthError,
@@ -64,8 +64,10 @@ class ProfileHandler:
         self.user_directory_handler = hs.get_user_directory_handler()
         self.request_ratelimiter = hs.get_request_ratelimiter()
 
-        self.max_avatar_size = hs.config.server.max_avatar_size
-        self.allowed_avatar_mimetypes = hs.config.server.allowed_avatar_mimetypes
+        self.max_avatar_size: Optional[int] = hs.config.server.max_avatar_size
+        self.allowed_avatar_mimetypes: Optional[List[str]] = (
+            hs.config.server.allowed_avatar_mimetypes
+        )
 
         self._is_mine_server_name = hs.is_mine_server_name
 
@@ -337,6 +339,12 @@ class ProfileHandler:
             return False
 
         if self.max_avatar_size:
+            if media_info.media_length is None:
+                logger.warning(
+                    "Forbidding avatar change to %s: unknown media size",
+                    mxc,
+                )
+                return False
             # Ensure avatar does not exceed max allowed avatar size
             if media_info.media_length > self.max_avatar_size:
                 logger.warning(