Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload: Coerce EmailMessage content-type header to str.

Alex Vandivere2d2d6e20446
diff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.py
index 35bc7542609..28988cc2e80 100644
--- a/zerver/lib/upload/__init__.py
+++ b/zerver/lib/upload/__init__.py
@@ -98,7 +98,7 @@ def maybe_add_charset(content_type: str, file_data: bytes | StreamingSourceWithS
# so we set a much lower threshold if that's the best guess.
# https://en.wikipedia.org/wiki/Popularity_of_text_encodings
fake_msg.set_param("charset", detected["encoding"], replace=True)
- return fake_msg["content-type"]
+ return str(fake_msg["content-type"])
def create_attachment(
@@ -154,7 +154,7 @@ def get_file_info(user_file: UploadedFile) -> tuple[str, str]:
if user_file.content_type_extra:
extras = {k: v.decode() if v else None for k, v in user_file.content_type_extra.items()}
fake_msg.add_header("content-type", content_type, **extras)
- content_type = fake_msg["content-type"]
+ content_type = str(fake_msg["content-type"])
uploaded_file_name = unquote(uploaded_file_name)