From c1c5fa7a5b02b196ef46a6e593f613d9cd139033 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 21 May 2019 14:50:10 +0200 Subject: [PATCH] Fixed list reply --- .../java/eu/faircode/email/MessageHelper.java | 23 +++++++++---------- 1 file changed, 11 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 57ddc0c390..49f39feac6 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.content.Context; +import android.net.MailTo; import android.text.TextUtils; import android.webkit.MimeTypeMap; @@ -590,24 +591,22 @@ public class MessageHelper { try { // https://www.ietf.org/rfc/rfc2369.txt String list = imessage.getHeader("List-Post", null); - if (list == null || "NO".equals(list)) + if (list == null) return null; list = MimeUtility.unfold(list); - - InternetAddress[] address = null; - try { - address = InternetAddress.parse(list); - } catch (AddressException ex) { - Log.w(ex); - } - - if (address == null || address.length == 0) + if ("NO".equals(list) || !list.startsWith("<") || !list.endsWith(">")) return null; - fix(address[0]); + // https://www.ietf.org/rfc/rfc2368.txt + MailTo to = MailTo.parse(list.substring(1, list.length() - 1)); + if (to.getTo() == null) + return null; - return new Address[]{address[0]}; + return new Address[]{new InternetAddress(to.getTo().split(",")[0])}; + } catch (android.net.ParseException ex) { + Log.w(ex); + return null; } catch (AddressException ex) { Log.w(ex); return null;