Merge pull request #25 from seamustuohy/empty_txt_files

Don't mark empty files as dangerous.
pull/26/head
Raphaël Vinot 2019-07-27 20:38:43 +02:00 committed by GitHub
commit 87e734b567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -192,9 +192,11 @@ class File(FileBase):
expected_mimetypes = [expected_mimetype]
if expected_mimetype in Config.aliases:
expected_mimetypes.append(Config.aliases[expected_mimetype])
if (encoding is None) and (os.path.getsize(self.src_path) == 0):
is_empty_file = True
is_known_extension = self.extension in mimetypes.types_map.keys()
if is_known_extension and self.mimetype not in expected_mimetypes:
if is_known_extension and self.mimetype not in expected_mimetypes and not is_empty_file:
self.make_dangerous('Mimetype does not match expected mimetypes ({}) for this extension'.format(expected_mimetypes))
def _check_mimetype(self):