Check URI against block lists

pull/203/head
M66B 3 years ago
parent df90a94e7b
commit 76e99796a5

@ -24,6 +24,7 @@ import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.core.net.MailTo;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import java.net.Inet4Address; import java.net.Inet4Address;
@ -162,7 +163,17 @@ public class DnsBlockList {
return (hasDomain ? false : null); return (hasDomain ? false : null);
} }
static Boolean isJunk(Context context, String domain) { static Boolean isJunk(Context context, Uri uri) {
String domain = null;
if ("mailto".equalsIgnoreCase(uri.getScheme())) {
MailTo email = MailTo.parse(uri.toString());
domain = UriHelper.getEmailDomain(email.getTo());
} else
domain = uri.getHost();
if (domain == null)
return null;
return isJunk(context, domain, false, BLOCK_LISTS); return isJunk(context, domain, false, BLOCK_LISTS);
} }

@ -408,13 +408,13 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
if (check_links_dbl && if (check_links_dbl &&
tvSuspicious.getVisibility() != View.VISIBLE) { tvSuspicious.getVisibility() != View.VISIBLE) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("host", host); args.putParcelable("uri", uri);
new SimpleTask<Boolean>() { new SimpleTask<Boolean>() {
@Override @Override
protected Boolean onExecute(Context context, Bundle args) throws Throwable { protected Boolean onExecute(Context context, Bundle args) throws Throwable {
String host = args.getString("host"); Uri uri = args.getParcelable("uri");
return DnsBlockList.isJunk(context, host); return DnsBlockList.isJunk(context, uri);
} }
@Override @Override

Loading…
Cancel
Save