mirror of https://github.com/zulip/zulip.git
Remove force_text() from sanitize_name().
This commit is contained in:
parent
17cfead19a
commit
a9f42e6266
|
@ -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
|
# Remove any extra '.' after file extension. These are probably added by the user
|
||||||
return re.sub('[.]+$', '', path_id_raw, re.M)
|
return re.sub('[.]+$', '', path_id_raw, re.M)
|
||||||
|
|
||||||
def sanitize_name(raw_value):
|
def sanitize_name(value):
|
||||||
# type: (NonBinaryStr) -> Text
|
# type: (NonBinaryStr) -> Text
|
||||||
"""
|
"""
|
||||||
Sanitizes a value to be safe to store in a Linux filesystem, in
|
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
|
This implementation is based on django.utils.text.slugify; it is
|
||||||
modified by:
|
modified by:
|
||||||
* hardcoding allow_unicode=True.
|
|
||||||
* adding '.' and '_' to the list of allowed characters.
|
* adding '.' and '_' to the list of allowed characters.
|
||||||
* preserving the case of the value.
|
* preserving the case of the value.
|
||||||
"""
|
"""
|
||||||
value = force_text(raw_value)
|
|
||||||
value = unicodedata.normalize('NFKC', value)
|
value = unicodedata.normalize('NFKC', value)
|
||||||
value = re.sub('[^\w\s._-]', '', value, flags=re.U).strip()
|
value = re.sub('[^\w\s._-]', '', value, flags=re.U).strip()
|
||||||
return mark_safe(re.sub('[-\s]+', '-', value, flags=re.U))
|
return mark_safe(re.sub('[-\s]+', '-', value, flags=re.U))
|
||||||
|
|
Loading…
Reference in New Issue