diff --git a/app/src/dummy/java/eu/faircode/email/Misc.java b/app/src/dummy/java/eu/faircode/email/Misc.java index 077eb788fb..b531abe5d6 100644 --- a/app/src/dummy/java/eu/faircode/email/Misc.java +++ b/app/src/dummy/java/eu/faircode/email/Misc.java @@ -19,11 +19,13 @@ package eu.faircode.email; Copyright 2018-2023 by Marcel Bokhorst (M66B) */ +import android.content.Context; + import java.util.ArrayList; import java.util.List; public class Misc { - public static List getISPDBUrls(String domain, String email) { + public static List getISPDBUrls(Context context, String domain, String email) { return new ArrayList<>(); } } \ No newline at end of file diff --git a/app/src/extra/java/eu/faircode/email/Misc.java b/app/src/extra/java/eu/faircode/email/Misc.java index 477fa17ffe..d20793c4cd 100644 --- a/app/src/extra/java/eu/faircode/email/Misc.java +++ b/app/src/extra/java/eu/faircode/email/Misc.java @@ -19,17 +19,34 @@ package eu.faircode.email; Copyright 2018-2023 by Marcel Bokhorst (M66B) */ +import android.content.Context; +import android.content.SharedPreferences; + +import androidx.preference.PreferenceManager; + +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Misc { - public static List getISPDBUrls(String domain, String email) { - return Collections.unmodifiableList(Arrays.asList( + public static List getISPDBUrls(Context context, String domain, String email) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean open_safe = prefs.getBoolean("open_safe", false); + + List result = new ArrayList<>(); + + result.addAll(Arrays.asList( "https://autoconfig." + domain + "/mail/config-v1.1.xml?emailaddress=" + email, - "https://" + domain + "/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=" + email, - "http://autoconfig." + domain + "/mail/config-v1.1.xml?emailaddress=" + email, - "http://" + domain + "/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=" + email + "https://" + domain + "/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=" + email )); + + if (!open_safe) + result.addAll(Arrays.asList( + "http://autoconfig." + domain + "/mail/config-v1.1.xml?emailaddress=" + email, + "http://" + domain + "/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=" + email + )); + + return Collections.unmodifiableList(result); } } diff --git a/app/src/main/java/eu/faircode/email/EmailProvider.java b/app/src/main/java/eu/faircode/email/EmailProvider.java index 30b8ec3e44..fe530138b1 100644 --- a/app/src/main/java/eu/faircode/email/EmailProvider.java +++ b/app/src/main/java/eu/faircode/email/EmailProvider.java @@ -614,7 +614,7 @@ public class EmailProvider implements Parcelable { @NonNull private static EmailProvider fromISPDB(Context context, String domain, String email, IDiscovery intf) throws Throwable { // https://wiki.mozilla.org/Thunderbird:Autoconfiguration - for (String link : Misc.getISPDBUrls(domain, email)) + for (String link : Misc.getISPDBUrls(context, domain, email)) try { URL url = new URL(link); return getISPDB(context, domain, url, true, intf);