From d213dae57cb3e49149bcfe9e0e46871c70e28af8 Mon Sep 17 00:00:00 2001 From: keykey7 <29210485+keykey7@users.noreply.github.com> Date: Wed, 11 Jan 2023 21:32:00 +0100 Subject: [PATCH 1/2] SPF ip-records have an optional prefix appended --- app/src/main/java/eu/faircode/email/ActivityDmarc.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityDmarc.java b/app/src/main/java/eu/faircode/email/ActivityDmarc.java index e84b9c1c91..9d2ecd14ac 100644 --- a/app/src/main/java/eu/faircode/email/ActivityDmarc.java +++ b/app/src/main/java/eu/faircode/email/ActivityDmarc.java @@ -272,9 +272,11 @@ public class ActivityDmarc extends ActivityBase { ip = ip.toLowerCase(Locale.ROOT); if (ip.startsWith("ip4:") || ip.startsWith("ip6:")) { String[] net = ip.substring(4).split("/"); - if (net.length != 2) + if (net.length > 2) continue; - Integer prefix = Helper.parseInt(net[1]); + Integer prefix = ip.startsWith("ip4:") ? 32 : 64; + if (net.length == 2) + prefix = Helper.parseInt(net[1]); if (prefix == null) continue; if (ConnectionHelper.inSubnet(text, net[0], prefix)) { From 901c4394a69b6a47724d35f9bb3aee2c52c8dadb Mon Sep 17 00:00:00 2001 From: keykey7 <29210485+keykey7@users.noreply.github.com> Date: Wed, 11 Jan 2023 21:37:25 +0100 Subject: [PATCH 2/2] ipv6 default prefix is 128 --- app/src/main/java/eu/faircode/email/ActivityDmarc.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityDmarc.java b/app/src/main/java/eu/faircode/email/ActivityDmarc.java index 9d2ecd14ac..e9dfb55ea1 100644 --- a/app/src/main/java/eu/faircode/email/ActivityDmarc.java +++ b/app/src/main/java/eu/faircode/email/ActivityDmarc.java @@ -274,7 +274,7 @@ public class ActivityDmarc extends ActivityBase { String[] net = ip.substring(4).split("/"); if (net.length > 2) continue; - Integer prefix = ip.startsWith("ip4:") ? 32 : 64; + Integer prefix = ip.startsWith("ip4:") ? 32 : 128; if (net.length == 2) prefix = Helper.parseInt(net[1]); if (prefix == null)