From 7a6d9dcab1e2e126d607c5e36a53fe43ee8249fe Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 28 May 2024 10:03:46 +0200 Subject: [PATCH] Native DKIM: strict alignment option --- app/src/main/java/eu/faircode/email/Core.java | 42 +++++++++++-------- .../faircode/email/FragmentOptionsMisc.java | 14 ++++++- .../main/res/layout/fragment_options_misc.xml | 14 ++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index de036a42ae..1cb00388f6 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3200,6 +3200,7 @@ class Core { boolean sync_quick_pop = prefs.getBoolean("sync_quick_pop", true); boolean notify_known = prefs.getBoolean("notify_known", false); boolean native_dkim = prefs.getBoolean("native_dkim", false); + boolean strict_alignment = prefs.getBoolean("strict_alignment", false); boolean download_eml = prefs.getBoolean("download_eml", false); boolean download_plain = prefs.getBoolean("download_plain", false); boolean check_blocklist = prefs.getBoolean("check_blocklist", false); @@ -3518,16 +3519,18 @@ class Core { message.dmarc = true; else if (message.dmarc != null) { boolean found = false; - String asigner = helper.getSigner(authentication); - String adomain = UriHelper.getRootDomain(context, asigner); - if (adomain != null) - for (String signer : signers) { - String sdomain = UriHelper.getRootDomain(context, signer); - if (adomain.equalsIgnoreCase(sdomain)) { - found = true; - break; + if (!strict_alignment) { + String asigner = helper.getSigner(authentication); + String adomain = UriHelper.getRootDomain(context, asigner); + if (adomain != null) + for (String signer : signers) { + String sdomain = UriHelper.getRootDomain(context, signer); + if (adomain.equalsIgnoreCase(sdomain)) { + found = true; + break; + } } - } + } if (!found) message.dmarc = false; } @@ -4435,6 +4438,7 @@ class Core { boolean download_plain = prefs.getBoolean("download_plain", false); boolean notify_known = prefs.getBoolean("notify_known", false); boolean native_dkim = prefs.getBoolean("native_dkim", false); + boolean strict_alignment = prefs.getBoolean("strict_alignment", false); boolean experiments = prefs.getBoolean("experiments", false); boolean mdn = prefs.getBoolean("mdn", experiments); boolean pro = ActivityBilling.isPro(context); @@ -4705,16 +4709,18 @@ class Core { message.dmarc = true; else if (message.dmarc != null) { boolean found = false; - String asigner = helper.getSigner(authentication); - String adomain = UriHelper.getRootDomain(context, asigner); - if (adomain != null) - for (String signer : signers) { - String sdomain = UriHelper.getRootDomain(context, signer); - if (adomain.equalsIgnoreCase(sdomain)) { - found = true; - break; + if (!strict_alignment) { + String asigner = helper.getSigner(authentication); + String adomain = UriHelper.getRootDomain(context, asigner); + if (adomain != null) + for (String signer : signers) { + String sdomain = UriHelper.getRootDomain(context, signer); + if (adomain.equalsIgnoreCase(sdomain)) { + found = true; + break; + } } - } + } if (!found) message.dmarc = false; } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index d4b2d35c61..c9d3277f22 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -217,6 +217,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swNativeDkim; private SwitchCompat swNativeArc; private EditText etNativeArcWhitelist; + private SwitchCompat swStrictAlignment; private SwitchCompat swWebp; private SwitchCompat swAnimate; private SwitchCompat swEasyCorrect; @@ -294,7 +295,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "keep_alive_poll", "empty_pool", "idle_done", "fast_fetch", "max_backoff_power", "logarithmic_backoff", "exact_alarms", - "native_dkim", "native_arc", "native_arc_whitelist", + "native_dkim", "native_arc", "native_arc_whitelist", "strict_alignment", "webp", "animate_images", "easy_correct", "paste_plain", "infra", "tld_flags", "json_ld", "dup_msgids", "thread_byref", "save_user_flags", "mdn", "app_chooser", "app_chooser_share", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape", @@ -465,6 +466,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swNativeDkim = view.findViewById(R.id.swNativeDkim); swNativeArc = view.findViewById(R.id.swNativeArc); etNativeArcWhitelist = view.findViewById(R.id.etNativeArcWhitelist); + swStrictAlignment = view.findViewById(R.id.swStrictAlignment); swWebp = view.findViewById(R.id.swWebp); swAnimate = view.findViewById(R.id.swAnimate); swEasyCorrect = view.findViewById(R.id.swEasyCorrect); @@ -1525,6 +1527,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc prefs.edit().putBoolean("native_dkim", checked).apply(); swNativeArc.setEnabled(checked && swNativeDkim.isEnabled()); etNativeArcWhitelist.setEnabled(checked && swNativeDkim.isEnabled()); + swStrictAlignment.setEnabled(checked && swNativeDkim.isEnabled()); } }); @@ -1553,6 +1556,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swStrictAlignment.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("strict_alignment", checked).apply(); + } + }); + swWebp.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -2419,6 +2429,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swNativeArc.setChecked(prefs.getBoolean("native_arc", true)); etNativeArcWhitelist.setEnabled(swNativeDkim.isEnabled() && swNativeDkim.isChecked()); etNativeArcWhitelist.setText(prefs.getString("native_arc_whitelist", null)); + swStrictAlignment.setChecked(prefs.getBoolean("strict_alignment", false)); + swStrictAlignment.setEnabled(swNativeDkim.isEnabled() && swNativeDkim.isChecked()); swWebp.setChecked(prefs.getBoolean("webp", true)); swAnimate.setChecked(prefs.getBoolean("animate_images", true)); swEasyCorrect.setChecked(prefs.getBoolean("easy_correct", false)); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 5c3d80d8dc..33cc94a885 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -1603,6 +1603,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swNativeArc" /> + + Use exact timers Native DKIM verification Native ARC verification + Strict alignment WebP Animate images (GIF, etc.) Easy correct