mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge branch 'evils-master'
This commit is contained in:
commit
c51d663731
@ -76,7 +76,8 @@ class Message(Loggable):
|
||||
continue
|
||||
|
||||
dispositions = content_disposition.strip().split(";")
|
||||
if not dispositions[0].lower() == "attachment":
|
||||
if not dispositions[0].lower() == "attachment" and \
|
||||
"filename" not in dispositions[1].lower():
|
||||
continue
|
||||
|
||||
file_data = part.get_payload()
|
||||
|
8044
src/documents/tests/samples/inline_mail.txt
Normal file
8044
src/documents/tests/samples/inline_mail.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -45,6 +45,40 @@ class TestMessage(TestCase):
|
||||
self.assertEqual(m.id_buffer(data), "application/pdf")
|
||||
|
||||
|
||||
class TestInlineMessage(TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
TestCase.__init__(self, *args, **kwargs)
|
||||
self.sample = os.path.join(
|
||||
settings.BASE_DIR,
|
||||
"documents",
|
||||
"tests",
|
||||
"samples",
|
||||
"inline_mail.txt"
|
||||
)
|
||||
|
||||
def test_init(self):
|
||||
|
||||
with open(self.sample, "rb") as f:
|
||||
|
||||
with mock.patch("logging.StreamHandler.emit") as __:
|
||||
message = Message(f.read())
|
||||
|
||||
self.assertTrue(message)
|
||||
self.assertEqual(message.subject, "Paperless Inline Image")
|
||||
|
||||
data = message.attachment.read()
|
||||
|
||||
self.assertEqual(
|
||||
md5(data).hexdigest(), "30c00a7b42913e65f7fdb0be40b9eef3")
|
||||
|
||||
self.assertEqual(
|
||||
message.attachment.content_type, "image/png")
|
||||
with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
|
||||
self.assertEqual(m.id_buffer(data), "image/png")
|
||||
|
||||
|
||||
class TestAttachment(TestCase):
|
||||
|
||||
def test_init(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user