diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 67ae22d1b7..03bf4be460 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1121,12 +1121,11 @@ public class MessageHelper { String[] h = origin.split("\\s+"); if (h.length > 1 && h[0].equalsIgnoreCase("from")) { String host = h[1]; - if (host.startsWith("[")) - host = host.substring(1); - if (host.endsWith("]")) - host = host.substring(0, host.length() - 1); - if (!TextUtils.isEmpty(host)) - return host; + int s = origin.indexOf('['); + int e = origin.indexOf(']'); + if (s > 0 && e > s + 1) + host = origin.substring(s + 1, e); + return host; } return null;