From 0197d736ffe435e0629b34fb4e7cd7b7d2cf79f7 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 24 Sep 2023 08:42:04 +0200 Subject: [PATCH] Consider DMARC with all NONE policies as neutral --- .../java/eu/faircode/email/MessageHelper.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 46a106be97..f1c7d11c9d 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -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;