Refactoring

pull/155/head
M66B 6 years ago
parent edeeea818e
commit 722012609b

@ -1174,9 +1174,9 @@ class Core {
// Local address contains control or whitespace in string ``mailing list someone@example.org''
message.deliveredto = helper.getDeliveredTo();
message.thread = helper.getThreadId(context, account.id, uid);
message.dkim = EntityMessage.getAuthentication("dkim", authentication);
message.spf = EntityMessage.getAuthentication("spf", authentication);
message.dmarc = EntityMessage.getAuthentication("dmarc", authentication);
message.dkim = MessageHelper.getAuthentication("dkim", authentication);
message.spf = MessageHelper.getAuthentication("spf", authentication);
message.dmarc = MessageHelper.getAuthentication("dmarc", authentication);
message.from = froms;
message.to = tos;
message.cc = ccs;

@ -185,31 +185,6 @@ public class EntityMessage implements Serializable {
}
}
static Boolean getAuthentication(String type, String header) {
if (header == null)
return null;
// https://tools.ietf.org/html/rfc7601
Boolean result = null;
String[] part = header.split(";");
for (int i = 1; i < part.length; i++) {
String[] kv = part[i].split("=");
if (kv.length > 1) {
String key = kv[0].trim();
String[] val = kv[1].split(" ");
if (val.length > 0 && type.equals(key)) {
if ("fail".equals(val[0]))
result = false;
else if ("pass".equals(val[0]))
if (result == null)
result = true;
}
}
}
return result;
}
public boolean uiEquals(Object obj) {
if (obj instanceof EntityMessage) {
EntityMessage other = (EntityMessage) obj;

@ -460,6 +460,31 @@ public class MessageHelper {
return (header == null ? null : header.replaceAll("\\r?\\n", ""));
}
static Boolean getAuthentication(String type, String header) {
if (header == null)
return null;
// https://tools.ietf.org/html/rfc7601
Boolean result = null;
String[] part = header.split(";");
for (int i = 1; i < part.length; i++) {
String[] kv = part[i].split("=");
if (kv.length > 1) {
String key = kv[0].trim();
String[] val = kv[1].trim().split(" ");
if (val.length > 0 && type.equals(key)) {
if ("fail".equals(val[0]))
result = false;
else if ("pass".equals(val[0]))
if (result == null)
result = true;
}
}
}
return result;
}
Address getSender() throws MessagingException {
String sender = imessage.getHeader("Sender", null);
if (sender == null)

Loading…
Cancel
Save