|
|
@ -2204,32 +2204,30 @@ public class MessageHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Address[] getMailFrom(String[] headers) {
|
|
|
|
Address[] getMailFrom(String[] headers) {
|
|
|
|
if (headers == null)
|
|
|
|
if (headers == null || headers.length == 0)
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
Address[] mailfrom = null;
|
|
|
|
Address[] mailfrom = null;
|
|
|
|
for (String header : headers) {
|
|
|
|
String spf = getKeyValues(headers[0]).get("spf");
|
|
|
|
String spf = getKeyValues(header).get("spf");
|
|
|
|
if (spf == null)
|
|
|
|
if (spf == null)
|
|
|
|
return null;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = spf.indexOf(SMTP_MAILFORM + "=");
|
|
|
|
int i = spf.indexOf(SMTP_MAILFORM + "=");
|
|
|
|
if (i < 0)
|
|
|
|
if (i < 0)
|
|
|
|
continue;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
String v = spf.substring(i + SMTP_MAILFORM.length() + 1);
|
|
|
|
String v = spf.substring(i + SMTP_MAILFORM.length() + 1);
|
|
|
|
int s = v.indexOf(' ');
|
|
|
|
int s = v.indexOf(' ');
|
|
|
|
if (s > 0)
|
|
|
|
if (s > 0)
|
|
|
|
v = v.substring(0, s);
|
|
|
|
v = v.substring(0, s);
|
|
|
|
|
|
|
|
|
|
|
|
if (v.startsWith("\"") && v.endsWith("\""))
|
|
|
|
if (v.startsWith("\"") && v.endsWith("\""))
|
|
|
|
v = v.substring(1, v.length() - 1);
|
|
|
|
v = v.substring(1, v.length() - 1);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
mailfrom = InternetAddress.parseHeader(v, false);
|
|
|
|
mailfrom = InternetAddress.parseHeader(v, false);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mailfrom;
|
|
|
|
return mailfrom;
|
|
|
|