From 54e26a1c9d69b1225033cfe0b58cf6dcfa2a1e8c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 10 Oct 2024 22:03:16 +0200 Subject: [PATCH] Allow sending invalid iCalendar files --- .../java/eu/faircode/email/MessageHelper.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index ac602830c2..db8ee8fc00 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1382,19 +1382,22 @@ public class MessageHelper { for (EntityAttachment attachment : attachments) if (attachment.available && - "text/calendar".equals(attachment.type)) { - File file = attachment.getFile(context); - ICalendar icalendar = CalendarHelper.parse(context, file); - Method method = (icalendar == null ? null : icalendar.getMethod()); - if (method != null && method.isReply()) { - // https://www.rfc-editor.org/rfc/rfc6047#section-2.4 - BodyPart calPart = new MimeBodyPart(); - calPart.setContent(icalendar.write(), attachment.type + ";" + - " method=" + method.getValue() + ";" + - " charset=UTF-8;"); - altMultiPart.addBodyPart(calPart); + "text/calendar".equals(attachment.type)) + try { + File file = attachment.getFile(context); + ICalendar icalendar = CalendarHelper.parse(context, file); + Method method = (icalendar == null ? null : icalendar.getMethod()); + if (method != null && method.isReply()) { + // https://www.rfc-editor.org/rfc/rfc6047#section-2.4 + BodyPart calPart = new MimeBodyPart(); + calPart.setContent(icalendar.write(), attachment.type + ";" + + " method=" + method.getValue() + ";" + + " charset=UTF-8;"); + altMultiPart.addBodyPart(calPart); + } + } catch (Throwable ex) { + Log.w(ex); } - } int availableAttachments = 0; boolean hasInline = false;