Stop scanning at tld

This commit is contained in:
M66B 2022-05-01 22:41:55 +02:00
parent a8020d4f05
commit f9418593ca
2 changed files with 14 additions and 0 deletions

View File

@ -426,6 +426,8 @@ public class EmailProvider implements Parcelable {
candidates.addAll(_fromDomain(context, target, email, discover));
int dot = target.indexOf('.');
target = target.substring(dot + 1);
if (UriHelper.isTld(context, target))
break;
}
}

View File

@ -94,6 +94,18 @@ public class UriHelper {
return (host != null && _getSuffix(context, host) != null);
}
static boolean isTld(Context context, String host) {
ensureSuffixList(context);
synchronized (suffixList) {
int d = host.indexOf('.');
String w = (d < 0 ? null : '*' + host.substring(d));
return (!suffixList.contains('!' + host) &&
!suffixList.contains(w) &&
suffixList.contains(host));
}
}
private static String _getSuffix(Context context, @NonNull String host) {
ensureSuffixList(context);