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: Strip out NULL bytes from the uploaded filename.

Alex Vandiverf31605d88595
diff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.py
index edb6f1831a8..d69e7d3d75d 100644
--- a/zerver/lib/upload/__init__.py
+++ b/zerver/lib/upload/__init__.py
@@ -233,6 +233,10 @@ def upload_message_attachment(
)
content_type = maybe_add_charset(content_type, file_data)
+ # NULL bytes are the one thing we can't store in the original
+ # filename column, due to PostgreSQL limitations
+ uploaded_file_name = re.sub(r"\x00", "", uploaded_file_name)
+
with transaction.atomic(durable=True):
upload_backend.upload_message_attachment(
path_id,