Consider DMARC with all NONE policies as neutral

This commit is contained in:
M66B 2023-09-24 08:42:04 +02:00
parent 036923b2b9
commit 0197d736ff
1 changed files with 17 additions and 2 deletions

View File

@ -2167,9 +2167,24 @@ public class MessageHelper {
continue;
String[] val = v.split("\\s+");
if (val.length > 0) {
if ("fail".equals(val[0]))
if ("fail".equals(val[0])) {
if ("dmarc".equals(type)) {
// dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=example.com
int s = v.indexOf('(');
int e = v.indexOf(')');
if (s > 0 && e > s) {
Boolean none = null;
for (String p : v.substring(s + 1, e).split("\\s+")) {
String[] kv = p.split("=");
if (kv.length == 2 && "none".equalsIgnoreCase(kv[1]))
none = (none == null || none) && "none".equalsIgnoreCase(kv[1]);
}
if (none != null && none)
continue; // neutral
}
}
result = false;
else if ("pass".equals(val[0])) {
} else if ("pass".equals(val[0])) {
// https://www.rfc-editor.org/rfc/rfc7489#section-3.1.1
if ("dkim".equals(type))
return true;