From a9f42e6266fb50bce72b1096f59a60d62f428668 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 4 Nov 2017 10:52:14 -0700 Subject: [PATCH] Remove force_text() from sanitize_name(). --- zerver/lib/upload.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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))