mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Handle non-ASCII filenames correctly when hashing the filename.
This commit is contained in:
parent
afadde4a6e
commit
c240f23b86
1 changed files with 2 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ from django.db import models
|
|||
from django.core.files.base import ContentFile
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.hashcompat import md5_constructor
|
||||
from django.utils.encoding import smart_str
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ def avatar_file_path(instance=None, filename=None, size=None, ext=None):
|
|||
# File doesn't exist yet
|
||||
if AVATAR_HASH_FILENAMES:
|
||||
(root, ext) = os.path.splitext(filename)
|
||||
filename = md5_constructor(filename).hexdigest()
|
||||
filename = md5_constructor(smart_str(filename)).hexdigest()
|
||||
filename = filename + ext
|
||||
if size:
|
||||
tmppath.extend(['resized', str(size)])
|
||||
|
|
|
|||
Loading…
Reference in a new issue