Feed back encoding information to the FileUploadForm when doing mime type validation, for later use in decoding.

- Legacy-Id: 14777
This commit is contained in:
Henrik Levkowetz 2018-03-13 13:51:00 +00:00
parent 2b52919c5e
commit c4bb28325a

View file

@ -329,9 +329,11 @@ class FileUploadForm(forms.Form):
file = self.cleaned_data['file']
validate_file_size(file)
ext = validate_file_extension(file, self.extensions)
mime_type = None
mime_type, encoding = validate_mime_type(file, self.mime_types)
if not hasattr(self, 'file_encoding'):
self.file_encoding = {}
self.file_encoding[file.name] = encoding.replace('charset=','') if encoding else None
if self.mime_types:
mime_type, encoding = validate_mime_type(file, self.mime_types)
if mime_type != file.content_type:
raise ValidationError('Upload Content-Type (%s) is different from the observed mime-type (%s)' % (file.content_type, mime_type))
if mime_type in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS: