Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
upload: Fix docstring and regex in sanitize_name regarding underscore.
Mateusz Mandera389c7bdb5aaa
diff --git a/zerver/lib/upload.py b/zerver/lib/upload.pyindex d4fabe146f9..c4756d43f9e 100644--- a/zerver/lib/upload.py+++ b/zerver/lib/upload.py@@ -87,11 +87,11 @@ def sanitize_name(value: str) -> str:This implementation is based on django.utils.text.slugify; it ismodified by:- * adding '.' and '_' to the list of allowed characters.+ * adding '.' to the list of allowed characters.* preserving the case of the value."""value = unicodedata.normalize("NFKC", value)- value = re.sub(r"[^\w\s._-]", "", value, flags=re.U).strip()+ value = re.sub(r"[^\w\s.-]", "", value, flags=re.U).strip()value = re.sub(r"[-\s]+", "-", value, flags=re.U)assert value not in {"", ".", ".."}return mark_safe(value)