This commit is contained in:
kurmaev 2014-12-30 19:40:51 +06:00
parent d3da18d1d2
commit fc3dc002da

View file

@ -39,7 +39,7 @@ class UploadAvatarForm(forms.Form):
"limitation")
# Construct 256 bytes needed for mime validation
magic_buffer = ""
magic_buffer = six.b('')
for chunk in data.chunks():
magic_buffer += chunk
if len(magic_buffer) >= 256:
@ -47,7 +47,8 @@ class UploadAvatarForm(forms.Form):
# https://github.com/ahupp/python-magic#usage
mime = magic.from_buffer(magic_buffer, mime=True)
if six.PY3:
mime = mime.decode('utf-8')
if mime not in settings.AVATAR_ALLOWED_MIMETYPES:
err = _(
"File content is invalid. Detected: %(mimetype)s "