Remove force_text() from sanitize_name().

This commit is contained in:
Steve Howell 2017-11-04 10:52:14 -07:00 committed by Tim Abbott
parent 17cfead19a
commit a9f42e6266
1 changed files with 1 additions and 3 deletions

View File

@ -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))