This commit is contained in:
M66B 2021-06-05 13:45:28 +02:00
parent 69da73f541
commit e3b053e260
2 changed files with 0 additions and 68 deletions

View File

@ -80,9 +80,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
@ -3349,49 +3346,6 @@ class Core {
message.warning = Log.formatThrowable(ex, false);
}
boolean check_spam = prefs.getBoolean("check_spam", false);
if (check_spam) {
String host = helper.getReceivedFromHost();
if (host != null) {
try {
InetAddress addr = InetAddress.getByName(host);
Log.i("Received from " + host + "=" + addr);
StringBuilder lookup = new StringBuilder();
if (addr instanceof Inet4Address) {
List<String> a = Arrays.asList(addr.getHostAddress().split("\\."));
Collections.reverse(a);
lookup.append(TextUtils.join(".", a)).append('.');
} else if (addr instanceof Inet6Address) {
StringBuilder sb = new StringBuilder();
byte[] a = addr.getAddress();
for (int i = 0; i < 8; i++)
sb.append(String.format("%02x",
((a[i << 1] << 8) & 0xff00) | (a[(i << 1) + 1] & 0xff)));
sb.reverse();
for (char kar : sb.toString().toCharArray())
lookup.append(kar).append('.');
}
lookup.append("zen.spamhaus.org");
try {
InetAddress.getByName(lookup.toString());
if (message.warning == null)
message.warning = lookup.toString();
else
message.warning += ", " + lookup;
} catch (UnknownHostException ignore) {
// Not blocked
}
} catch (UnknownHostException ex) {
Log.w(ex);
} catch (Throwable ex) {
Log.w(folder.name, ex);
}
}
}
try {
db.beginTransaction();

View File

@ -1203,28 +1203,6 @@ public class MessageHelper {
return result;
}
String getReceivedFromHost() throws MessagingException {
ensureHeaders();
String[] received = imessage.getHeader("Received");
if (received == null || received.length == 0)
return null;
String origin = MimeUtility.unfold(received[received.length - 1]);
String[] h = origin.split("\\s+");
if (h.length > 1 && h[0].equalsIgnoreCase("from")) {
String host = h[1];
int s = origin.indexOf('[');
int e = origin.indexOf(']');
if (s > 0 && e > s + 1)
host = origin.substring(s + 1, e);
return host;
}
return null;
}
private String fixEncoding(String name, String header) {
if (header.trim().startsWith("=?"))
return header;