Using get_valid_filename to sanitize attachment names
parent
485799918e
commit
8742f0cabb
|
@ -27,16 +27,14 @@ from django.contrib.contenttypes import generic
|
|||
from django.utils import timezone
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.text import get_valid_filename
|
||||
|
||||
from taiga.base.utils.iterators import split_by_n
|
||||
|
||||
|
||||
def get_attachment_file_path(instance, filename):
|
||||
basename = path.basename(filename).lower()
|
||||
base, ext = path.splitext(basename)
|
||||
base = slugify(unidecode(base))
|
||||
basename = "".join([base, ext])
|
||||
basename = get_valid_filename(basename)
|
||||
|
||||
hs = hashlib.sha256()
|
||||
hs.update(force_bytes(timezone.now().isoformat()))
|
||||
|
|
Loading…
Reference in New Issue