Prevent blocking common domain names

This commit is contained in:
M66B
2020-04-19 16:57:40 +02:00
parent 6110ff0aa6
commit 242e0a0fd0
4 changed files with 32 additions and 5 deletions

View File

@@ -540,14 +540,23 @@ public class EntityRule {
return cal;
}
static EntityRule blockSender(Context context, EntityMessage message, EntityFolder junk, boolean block_domain) throws JSONException {
static EntityRule blockSender(Context context, EntityMessage message, EntityFolder junk, boolean block_domain, List<String> whitelist) throws JSONException {
String sender = ((InternetAddress) message.from[0]).getAddress();
String name = MessageHelper.formatAddresses(new Address[]{message.from[0]});
if (block_domain) {
int at = sender.indexOf('@');
if (at > 0)
sender = sender.substring(at);
if (at > 0) {
boolean whitelisted = false;
String domain = sender.substring(at + 1);
for (String d : whitelist)
if (domain.matches(d)) {
whitelisted = true;
break;
}
if (!whitelisted)
sender = '@' + domain;
}
}
JSONObject jsender = new JSONObject();