Reject email attachments of size 0

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-04-06 19:57:50 -04:00
parent 5de6fbe914
commit 97fb5f96a7
4 changed files with 49 additions and 5 deletions
@@ -121,6 +121,11 @@ class EmailBaseModel(IntervalBaseModel):
# Treat inlines as attachments, both are extracted and saved as
# documents
if message.is_attachment() or message.is_inline():
# Reject zero length attachments
if len(message.body) == 0:
return
label = message.detected_file_name or 'attachment-{}'.format(counter)
with ContentFile(content=message.body, name=label) as file_object:
if label == source.metadata_attachment_name: