diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index 472f5f71a1..480c0d3e30 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -59,7 +59,7 @@ def attachment_url_to_path_id(attachment_url): # Remove any extra '.' after file extension. These are probably added by the user return re.sub('[.]+$', '', path_id_raw, re.M) -def sanitize_name(raw_value): +def sanitize_name(value): # type: (NonBinaryStr) -> Text """ Sanitizes a value to be safe to store in a Linux filesystem, in @@ -68,11 +68,9 @@ def sanitize_name(raw_value): This implementation is based on django.utils.text.slugify; it is modified by: - * hardcoding allow_unicode=True. * adding '.' and '_' to the list of allowed characters. * preserving the case of the value. """ - value = force_text(raw_value) value = unicodedata.normalize('NFKC', value) value = re.sub('[^\w\s._-]', '', value, flags=re.U).strip() return mark_safe(re.sub('[-\s]+', '-', value, flags=re.U))