From 52b7534155b4c571e294f956b8b0e12d2fefb080 Mon Sep 17 00:00:00 2001
From: Oliver Wiese <oliver.wiese@fu-berlin.de>
Date: Fri, 14 Jun 2019 12:28:21 -0700
Subject: [PATCH] fix no title in attachment bug

---
 enzevalos_iphone/mail/IncomingMail.swift | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/enzevalos_iphone/mail/IncomingMail.swift b/enzevalos_iphone/mail/IncomingMail.swift
index 20b65412..c7cd0b23 100644
--- a/enzevalos_iphone/mail/IncomingMail.swift
+++ b/enzevalos_iphone/mail/IncomingMail.swift
@@ -652,11 +652,21 @@ class IncomingMail {
     private func parseUserReadableAttachments(parser: MCOMessageParser, sentEncrypted: Bool = false) -> Set<TempAttachment> {
         var attachments = Set<TempAttachment>()
         for at in parser.attachments() {
-            if let attachment = at as? MCOAttachment, let mimetype = MIMETYPE.findMIMETYPE(attachment: attachment) {
+            if let attachment = at as? MCOAttachment, let mimetype = MIMETYPE.findMIMETYPE(attachment: attachment), attachment.data.count > 0 {
                 if (mimetype == .travelUse || mimetype == .travelRepeal) && !sentEncrypted {
                     continue
                 }
-                attachments.insert(TempAttachment(name: attachment.filename, data: attachment.data, mimeType: mimetype))
+                print(attachment.filename)
+                print(attachment.data.count)
+                print(mimetype)
+                print(attachment.decodedString())
+                print(attachment.contentID)
+                print(attachment.description)
+                var name = "untitled"
+                if let n = attachment.filename {
+                    name = n
+                }
+                attachments.insert(TempAttachment(name: name, data: attachment.data, mimeType: mimetype))
             }
         }
         return attachments
-- 
GitLab