From 420d78efebcb1e211267eed77de2ad7a62af51ac Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 24 May 2024 08:12:45 +0200 Subject: [PATCH] Refactoring --- .../java/eu/faircode/email/MessageHelper.java | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 18e32bde8d..2bd6b6d67d 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -2203,6 +2203,38 @@ public class MessageHelper { return false; // fail, policy, neutral, temperror, permerror } + Address[] getMailFrom(String[] headers) { + if (headers == null) + return null; + + Address[] mailfrom = null; + for (String header : headers) { + String spf = getKeyValues(header).get("spf"); + if (spf == null) + continue; + + int i = spf.indexOf(SMTP_MAILFORM + "="); + if (i < 0) + continue; + + String v = spf.substring(i + SMTP_MAILFORM.length() + 1); + int s = v.indexOf(' '); + if (s > 0) + v = v.substring(0, s); + + if (v.startsWith("\"") && v.endsWith("\"")) + v = v.substring(1, v.length() - 1); + + try { + mailfrom = InternetAddress.parseHeader(v, false); + } catch (Throwable ex) { + Log.w(ex); + } + } + + return mailfrom; + } + boolean getSPF() throws MessagingException { ensureHeaders(); @@ -2608,38 +2640,6 @@ public class MessageHelper { return false; } - Address[] getMailFrom(String[] headers) { - if (headers == null) - return null; - - Address[] mailfrom = null; - for (String header : headers) { - String spf = getKeyValues(header).get("spf"); - if (spf == null) - continue; - - int i = spf.indexOf(SMTP_MAILFORM + "="); - if (i < 0) - continue; - - String v = spf.substring(i + SMTP_MAILFORM.length() + 1); - int s = v.indexOf(' '); - if (s > 0) - v = v.substring(0, s); - - if (v.startsWith("\"") && v.endsWith("\"")) - v = v.substring(1, v.length() - 1); - - try { - mailfrom = InternetAddress.parseHeader(v, false); - } catch (Throwable ex) { - Log.w(ex); - } - } - - return mailfrom; - } - private String fixEncoding(String name, String header) { if (header.trim().startsWith("=?")) return header;