1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Allow multiple Authentication-Results headers with the same signer

This commit is contained in:
M66B 2024-05-29 16:14:34 +02:00
parent ee2be885fc
commit 4ef53b4da6

View file

@ -2188,13 +2188,20 @@ public class MessageHelper {
if (headers == null || headers.length == 0) if (headers == null || headers.length == 0)
return null; return null;
String v = getKeyValues(headers[0]).get(type); String signer = null;
for (String header : headers) {
if (signer == null)
signer = getSigner(header);
else if (!signer.equals(getSigner(header)))
break;
String v = getKeyValues(header).get(type);
if (v == null) if (v == null)
return null; continue;
String[] val = v.split("\\s+"); String[] val = v.split("\\s+");
if (val.length == 0) if (val.length == 0)
return null; continue;
if ("pass".equals(val[0])) if ("pass".equals(val[0]))
return true; return true;
@ -2204,6 +2211,9 @@ public class MessageHelper {
return false; // fail, policy, neutral, temperror, permerror return false; // fail, policy, neutral, temperror, permerror
} }
return null;
}
Address[] getMailFrom(String[] headers) { Address[] getMailFrom(String[] headers) {
if (headers == null || headers.length == 0) if (headers == null || headers.length == 0)
return null; return null;
@ -2234,20 +2244,26 @@ public class MessageHelper {
return mailfrom; return mailfrom;
} }
String getSigner(String[] headers) { static String getSigner(String[] headers) {
if (headers == null || headers.length == 0) if (headers == null || headers.length == 0)
return null; return null;
return getSigner(headers[0]);
}
int semi = headers[0].indexOf(';'); static String getSigner(String header) {
if (TextUtils.isEmpty(header))
return null;
int semi = header.indexOf(';');
if (semi < 0) if (semi < 0)
return null; return null;
String signer = headers[0].substring(0, semi).trim(); String signer = header.substring(0, semi).trim();
if (signer.toLowerCase(Locale.ROOT).startsWith("i=")) { if (signer.toLowerCase(Locale.ROOT).startsWith("i=")) {
int semi2 = headers[0].indexOf(';', semi + 1); int semi2 = header.indexOf(';', semi + 1);
if (semi2 < 0) if (semi2 < 0)
return null; return null;
signer = headers[0].substring(semi + 1, semi2).trim(); signer = header.substring(semi + 1, semi2).trim();
} }
if (TextUtils.isEmpty(signer)) if (TextUtils.isEmpty(signer))