From 5ffd56869ab01451ff3d1acbab0f9fdb36494116 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 9 Jun 2019 15:46:36 +0200 Subject: [PATCH] Imporved List-Post header parsing --- .../java/eu/faircode/email/MessageHelper.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index a972605c4d..27c7f5cf56 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -603,18 +603,20 @@ public class MessageHelper { if ("NO".equals(list)) return null; - String[] to = list.split(","); - if (to.length < 1 || !to[0].startsWith("<") || !to[0].endsWith(">")) - return null; - // https://www.ietf.org/rfc/rfc2368.txt - MailTo mailto = MailTo.parse(to[0].substring(1, to[0].length() - 1)); - if (mailto.getTo() == null) - return null; + for (String _to : list.split(",")) { + String to = _to.trim(); + if (to.startsWith("<") && to.endsWith(">")) + try { + MailTo mailto = MailTo.parse(to.substring(1, to.length() - 1)); + if (mailto.getTo() != null) + return new Address[]{new InternetAddress(mailto.getTo().split(",")[0])}; + } catch (android.net.ParseException ex) { + Log.i(ex); + } + } - return new Address[]{new InternetAddress(mailto.getTo().split(",")[0])}; - } catch (android.net.ParseException ex) { - Log.w(new IllegalArgumentException(list, ex)); + Log.w(new IllegalArgumentException("List-Post: " + list)); return null; } catch (AddressException ex) { Log.w(ex);