mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 00:21:10 +00:00
Stricter alignment
This commit is contained in:
parent
af63bd1443
commit
d11bf4a73b
3 changed files with 16 additions and 47 deletions
|
@ -359,7 +359,7 @@ public class ActivityEML extends ActivityBase {
|
|||
|
||||
List<String> signers = helper.verifyDKIM(context);
|
||||
boolean aligned = helper.isAligned(context, signers,
|
||||
helper.getReturnPath(), helper.getMailFrom(authentication), helper.getFrom());
|
||||
helper.getReturnPath(), helper.getMailFrom(authentication), helper.getFrom(), helper.getSPF());
|
||||
|
||||
ssb.append("TLS: ").append(tls == null ? "-" : (tls ? "✓" : "✗")).append('\n');
|
||||
ssb.append("DKIM: ").append(dkim == null ? "-" : (dkim ? "✓" : "✗")).append('\n');
|
||||
|
|
|
@ -3514,28 +3514,8 @@ class Core {
|
|||
List<String> signers = helper.verifyDKIM(context);
|
||||
message.dkim = !signers.isEmpty();
|
||||
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
|
||||
if (message.dkim) {
|
||||
boolean aligned = helper.isAligned(context, signers, message.return_path, message.smtp_from, message.from);
|
||||
if (aligned)
|
||||
message.dmarc = true;
|
||||
else if (message.dmarc != null) {
|
||||
boolean found = false;
|
||||
if (!strict_alignment) {
|
||||
String asigner = helper.getSigner(authentication);
|
||||
String adomain = UriHelper.getRootDomain(context, asigner);
|
||||
if (adomain != null)
|
||||
for (String signer : signers) {
|
||||
String sdomain = UriHelper.getRootDomain(context, signer);
|
||||
if (adomain.equalsIgnoreCase(sdomain)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
message.dmarc = false;
|
||||
}
|
||||
}
|
||||
message.dmarc = helper.isAligned(context, signers,
|
||||
message.return_path, message.smtp_from, message.from, helper.getSPF());
|
||||
}
|
||||
|
||||
if (message.size == null && message.total != null)
|
||||
|
@ -4721,28 +4701,8 @@ class Core {
|
|||
List<String> signers = helper.verifyDKIM(context);
|
||||
message.dkim = !signers.isEmpty();
|
||||
message.signedby = (signers.isEmpty() ? null : TextUtils.join(",", signers));
|
||||
if (message.dkim) {
|
||||
boolean aligned = helper.isAligned(context, signers, message.return_path, message.smtp_from, message.from);
|
||||
if (aligned)
|
||||
message.dmarc = true;
|
||||
else if (message.dmarc != null) {
|
||||
boolean found = false;
|
||||
if (!strict_alignment) {
|
||||
String asigner = helper.getSigner(authentication);
|
||||
String adomain = UriHelper.getRootDomain(context, asigner);
|
||||
if (adomain != null)
|
||||
for (String signer : signers) {
|
||||
String sdomain = UriHelper.getRootDomain(context, signer);
|
||||
if (adomain.equalsIgnoreCase(sdomain)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
message.dmarc = false;
|
||||
}
|
||||
}
|
||||
message.dmarc = helper.isAligned(context, signers,
|
||||
message.return_path, message.smtp_from, message.from, helper.getSPF());
|
||||
}
|
||||
|
||||
// Borrow reply name from sender name
|
||||
|
|
|
@ -2718,13 +2718,18 @@ public class MessageHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean isAligned(Context context, List<String> signers, Address[] return_path, Address[] smtp_from, Address[] from) {
|
||||
boolean isAligned(Context context, List<String> signers,
|
||||
Address[] return_path, Address[] smtp_from, Address[] from,
|
||||
Boolean spf) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean strict_alignment = prefs.getBoolean("strict_alignment", false);
|
||||
|
||||
List<Address> envelop = new ArrayList<>();
|
||||
if (return_path != null)
|
||||
envelop.addAll(Arrays.asList(return_path));
|
||||
if (from != null)
|
||||
envelop.addAll(Arrays.asList(from));
|
||||
if (smtp_from != null)
|
||||
if (smtp_from != null && !strict_alignment)
|
||||
envelop.addAll(Arrays.asList(smtp_from));
|
||||
for (String signer : signers) {
|
||||
String sdomain = UriHelper.getRootDomain(context, signer);
|
||||
|
@ -2736,6 +2741,10 @@ public class MessageHelper {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(spf) && !strict_alignment)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue