feed mail: use FileContent to avoid SuspiciousOperation (#59894)

This commit is contained in:
Frédéric Péters 2021-12-19 17:46:51 +01:00
parent f934f78403
commit 2a287e61b9
1 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@
import os
from optparse import make_option
from django.core.files import File
from django.core.files.base import ContentFile
from django.core.management.base import BaseCommand, CommandError
from ...models import Mail
@ -35,7 +35,7 @@ class Command(BaseCommand):
continue
if not open(filepath).read(5) == '%PDF-':
continue
mail = Mail(content=File(open(filepath)))
mail = Mail(content=ContentFile(open(filepath).read(), name=os.path.basename(filepath)))
mail.scanner_category = kwargs.get('category')
mail.save()
count += 1