From 1ae779b151f85078fb392ee671950786fe316af0 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 13 Mar 2022 17:23:36 +0100 Subject: [PATCH] Added BIMI/DMARC pct check --- app/src/main/java/eu/faircode/email/Bimi.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Bimi.java b/app/src/main/java/eu/faircode/email/Bimi.java index 2dd9054b0b..2dc39f8b48 100644 --- a/app/src/main/java/eu/faircode/email/Bimi.java +++ b/app/src/main/java/eu/faircode/email/Bimi.java @@ -338,10 +338,15 @@ public class Bimi { Log.i("BIMI got TXT " + records[0].name); Map dmarc = MessageHelper.getKeyValues(records[0].name); - String policy = dmarc.get("p"); - if (policy == null || - !DMARC_POLICIES.contains(policy.toLowerCase(Locale.ROOT))) - throw new IllegalArgumentException("DMARC invalid policy=" + policy); + + String p = dmarc.get("p"); + if (p == null || + !DMARC_POLICIES.contains(p.toLowerCase(Locale.ROOT))) + throw new IllegalArgumentException("DMARC invalid p=" + p); + + String pct = dmarc.get("pct"); + if (!TextUtils.isEmpty(pct) && !"100".equals(pct)) + throw new IllegalArgumentException("DMARC invalid pct=" + p); verified = true; } catch (MalformedURLException ex) {