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
1 changed files with 33 additions and 17 deletions

View File

@ -2188,20 +2188,30 @@ 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;
if (v == null) for (String header : headers) {
return null; if (signer == null)
signer = getSigner(header);
else if (!signer.equals(getSigner(header)))
break;
String[] val = v.split("\\s+"); String v = getKeyValues(header).get(type);
if (val.length == 0) if (v == null)
return null; continue;
if ("pass".equals(val[0])) String[] val = v.split("\\s+");
return true; if (val.length == 0)
else if ("none".equals(val[0])) continue;
return null;
else if ("pass".equals(val[0]))
return false; // fail, policy, neutral, temperror, permerror return true;
else if ("none".equals(val[0]))
return null;
else
return false; // fail, policy, neutral, temperror, permerror
}
return null;
} }
Address[] getMailFrom(String[] headers) { Address[] getMailFrom(String[] headers) {
@ -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))