Check for qmail / Postfix in first added received header only

pull/194/merge
M66B 3 years ago
parent c2a56ab69b
commit 3a7af8a57c

@ -4479,8 +4479,8 @@ To show shields, the option *Show authentication status indicator* in the displa
A message will be consired safely transported if *every* [Received](https://datatracker.ietf.org/doc/html/rfc2821#section-4.4) header: A message will be consired safely transported if *every* [Received](https://datatracker.ietf.org/doc/html/rfc2821#section-4.4) header:
* contains the phrase 'using TLS', 'via HTTP', 'version=TLS' * contains the phrase 'using TLS', 'via HTTP', 'version=TLS'
* contains the phrase '(qmail <nnn> invoked by uid <nnn>)' * contains the phrase '(qmail <nnn> invoked by uid <nnn>)' in the first added header
* contains the phrase '(Postfix, from userid nnn)' * contains the phrase '(Postfix, from userid nnn)' in the first added header
* has a *by* with a local address * has a *by* with a local address
* has a *by* xxx.google.com * has a *by* xxx.google.com
* has a *from* with a local address * has a *from* with a local address

@ -2471,7 +2471,7 @@ public class HtmlHelper {
j++; j++;
} }
Boolean tls = MessageHelper.isTLS(h); Boolean tls = MessageHelper.isTLS(h, i == received.length - 1);
ssb.append(" TLS="); ssb.append(" TLS=");
int t = ssb.length(); int t = ssb.length();
ssb.append(tls == null ? "?" : Boolean.toString(tls)); ssb.append(tls == null ? "?" : Boolean.toString(tls));

@ -2076,10 +2076,10 @@ public class MessageHelper {
// First header is last added header // First header is last added header
Log.i("======="); Log.i("=======");
for (String r : received) { for (int i = 0; i < received.length; i++) {
String header = MimeUtility.unfold(r); String header = MimeUtility.unfold(received[i]);
Log.i("--- header=" + header); Log.i("--- header=" + header);
Boolean tls = isTLS(header); Boolean tls = isTLS(header, i == received.length - 1);
if (!Boolean.TRUE.equals(tls)) if (!Boolean.TRUE.equals(tls))
return tls; return tls;
} }
@ -2087,7 +2087,7 @@ public class MessageHelper {
return true; return true;
} }
static Boolean isTLS(String header) { static Boolean isTLS(String header, boolean first) {
// Strip date // Strip date
int semi = header.lastIndexOf(';'); int semi = header.lastIndexOf(';');
if (semi > 0) if (semi > 0)
@ -2102,8 +2102,9 @@ public class MessageHelper {
// (qmail nnn invoked by uid nnn); 1 Jan 2022 00:00:00 -0000 // (qmail nnn invoked by uid nnn); 1 Jan 2022 00:00:00 -0000
// by <host name> (Postfix, from userid nnn) // by <host name> (Postfix, from userid nnn)
if (header.matches(".*\\(qmail \\d+ invoked by uid \\d+\\).*") || if (first &&
header.matches(".*\\(Postfix, from userid \\d+\\).*")) { (header.matches(".*\\(qmail \\d+ invoked by uid \\d+\\).*") ||
header.matches(".*\\(Postfix, from userid \\d+\\).*"))) {
Log.i("--- phrase"); Log.i("--- phrase");
return true; return true;
} }

Loading…
Cancel
Save