Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_settings: Trust the content-type the browser sends for avatars.
Alex Vandiver9b7b22b6a09b
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex 300d0b3bfee..dd1e038b50c 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -557,7 +557,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpRmax_size=settings.MAX_AVATAR_FILE_SIZE_MIB,))- upload_avatar_image(user_file, user_profile)+ upload_avatar_image(user_file, user_profile, content_type=user_file.content_type)do_change_avatar_fields(user_profile, UserProfile.AVATAR_FROM_USER, acting_user=user_profile)user_avatar_url = avatar_url(user_profile)diff --git a/zerver/views/users.py b/zerver/views/users.pyindex 41f3ebe441a..bcc1e827c06 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -526,7 +526,7 @@ def patch_bot_backend([user_file] = request.FILES.values()assert isinstance(user_file, UploadedFile)assert user_file.size is not None- upload_avatar_image(user_file, bot)+ upload_avatar_image(user_file, bot, content_type=user_file.content_type)avatar_source = UserProfile.AVATAR_FROM_USERdo_change_avatar_fields(bot, avatar_source, acting_user=user_profile)else:@@ -674,7 +674,9 @@ def add_bot_backend([user_file] = request.FILES.values()assert isinstance(user_file, UploadedFile)assert user_file.size is not None- upload_avatar_image(user_file, bot_profile, future=False)+ upload_avatar_image(+ user_file, bot_profile, content_type=user_file.content_type, future=False+ )if bot_type in (UserProfile.OUTGOING_WEBHOOK_BOT, UserProfile.EMBEDDED_BOT):assert isinstance(service_name, str)