Tweaked the mime type validator so it can be called also when there's no required mime types.

- Legacy-Id: 14779
This commit is contained in:
Henrik Levkowetz 2018-03-13 13:54:04 +00:00
parent 07229b7406
commit 02105889b6

View file

@ -80,7 +80,7 @@ def validate_mime_type(file, valid):
if mime_type == 'text/x-c++' and re.search('(?m)^virtual\s', raw):
mod = raw.replace(str('virtual'), str(' virtual'))
mime_type, encoding = get_mime_type(mod)
if not mime_type in valid:
if valid and not mime_type in valid:
raise ValidationError('Found content with unexpected mime type: %s. Expected one of %s.' %
(mime_type, ', '.join(valid) ))
return mime_type, encoding