diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 2afd296ec5..9f44d2ad75 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -6650,24 +6650,20 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. byte[] keydata = null; // https://autocrypt.org/level1.html#the-autocrypt-header - String[] param = message.autocrypt.split(";"); - for (int i = 0; i < param.length; i++) { - int e = param[i].indexOf("="); - if (e > 0) { - String key = param[i].substring(0, e).trim().toLowerCase(Locale.ROOT); - String value = param[i].substring(e + 1); - Log.i("Autocrypt " + key + "=" + value); - switch (key) { - case "addr": - addr = value; - break; - case "prefer-encrypt": - mutual = value.trim().toLowerCase(Locale.ROOT).equals("mutual"); - break; - case "keydata": - keydata = Base64.decode(value, Base64.DEFAULT); - break; - } + Map kv = MessageHelper.getKeyValues(message.autocrypt); + for (String key : kv.keySet()) { + String value = kv.get(key).toLowerCase(Locale.ROOT); + Log.i("Autocrypt " + key + "=" + value); + switch (key) { + case "addr": + addr = value; + break; + case "prefer-encrypt": + mutual = value.trim().toLowerCase(Locale.ROOT).equals("mutual"); + break; + case "keydata": + keydata = Base64.decode(value, Base64.DEFAULT); + break; } }