From 8c1ad78caf27108b2201663071623b27350e7ce9 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 2 Aug 2018 20:32:47 +0000 Subject: [PATCH] Fixed reply to messages without sender --- .../java/eu/faircode/email/MessageHelper.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index d653c1c7..69ab09a0 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -176,21 +176,22 @@ public class MessageHelper { static Address[] decodeAddresses(String json) { List
result = new ArrayList<>(); - try { - JSONArray jaddresses = new JSONArray(json); - for (int i = 0; i < jaddresses.length(); i++) { - JSONObject jaddress = (JSONObject) jaddresses.get(i); - if (jaddress.has("personal")) - result.add(new InternetAddress( - jaddress.getString("address"), - jaddress.getString("personal"))); - else - result.add(new InternetAddress( - jaddress.getString("address"))); + if (json != null) + try { + JSONArray jaddresses = new JSONArray(json); + for (int i = 0; i < jaddresses.length(); i++) { + JSONObject jaddress = (JSONObject) jaddresses.get(i); + if (jaddress.has("personal")) + result.add(new InternetAddress( + jaddress.getString("address"), + jaddress.getString("personal"))); + else + result.add(new InternetAddress( + jaddress.getString("address"))); + } + } catch (Throwable ex) { + Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); } - } catch (Throwable ex) { - Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); - } return result.toArray(new Address[0]); }