mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-01 14:46:31 +02:00
Block sender's parent domain
This commit is contained in:
@@ -655,24 +655,27 @@ public class EntityRule {
|
||||
if (TextUtils.isEmpty(sender))
|
||||
return null;
|
||||
|
||||
boolean regex = false;
|
||||
if (block_domain) {
|
||||
int at = sender.indexOf('@');
|
||||
if (at > 0) {
|
||||
boolean whitelisted = false;
|
||||
String domain = sender.substring(at + 1);
|
||||
String domain = DnsHelper.getParentDomain(sender.substring(at + 1));
|
||||
for (String d : whitelist)
|
||||
if (domain.matches(d)) {
|
||||
whitelisted = true;
|
||||
break;
|
||||
}
|
||||
if (!whitelisted)
|
||||
sender = '@' + domain;
|
||||
if (!whitelisted) {
|
||||
regex = true;
|
||||
sender = ".*@.*" + domain + ".*";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject jsender = new JSONObject();
|
||||
jsender.put("value", sender);
|
||||
jsender.put("regex", false);
|
||||
jsender.put("regex", regex);
|
||||
|
||||
JSONObject jcondition = new JSONObject();
|
||||
jcondition.put("sender", jsender);
|
||||
|
||||
Reference in New Issue
Block a user