Imporved List-Post header parsing

This commit is contained in:
M66B 2019-06-09 15:46:36 +02:00
parent cf35d058ad
commit 5ffd56869a
1 changed files with 12 additions and 10 deletions

View File

@ -603,18 +603,20 @@ public class MessageHelper {
if ("NO".equals(list)) if ("NO".equals(list))
return null; 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 // https://www.ietf.org/rfc/rfc2368.txt
MailTo mailto = MailTo.parse(to[0].substring(1, to[0].length() - 1)); for (String _to : list.split(",")) {
if (mailto.getTo() == null) String to = _to.trim();
return null; 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])}; return new Address[]{new InternetAddress(mailto.getTo().split(",")[0])};
} catch (android.net.ParseException ex) { } catch (android.net.ParseException ex) {
Log.w(new IllegalArgumentException(list, ex)); Log.i(ex);
}
}
Log.w(new IllegalArgumentException("List-Post: " + list));
return null; return null;
} catch (AddressException ex) { } catch (AddressException ex) {
Log.w(ex); Log.w(ex);