Geary.RFC822.Message: Add support for Authentication-Results field
This commit is contained in:
parent
c1cbd6e111
commit
bc4fe28a25
2 changed files with 43 additions and 0 deletions
|
|
@ -619,3 +619,25 @@ public class Geary.RFC822.PreviewText : Geary.RFC822.Text {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Geary.RFC822.AuthenticationResults :
|
||||||
|
Geary.MessageData.StringMessageData {
|
||||||
|
|
||||||
|
public AuthenticationResults(string value) {
|
||||||
|
base(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the authentication result for dkim.
|
||||||
|
*/
|
||||||
|
public bool is_dkim_valid() {
|
||||||
|
return /^.*;[ ]*dkim=pass.*$/i.match(this.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the authentication result for dmarc.
|
||||||
|
*/
|
||||||
|
public bool is_dmarc_valid() {
|
||||||
|
return /^.*;[ ]*dmarc=pass.*$/i.match(this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
|
||||||
private const string HEADER_REFERENCES = "References";
|
private const string HEADER_REFERENCES = "References";
|
||||||
private const string HEADER_MAILER = "X-Mailer";
|
private const string HEADER_MAILER = "X-Mailer";
|
||||||
private const string HEADER_BCC = "Bcc";
|
private const string HEADER_BCC = "Bcc";
|
||||||
|
private const string[] HEADER_AUTH_RESULTS = {
|
||||||
|
"ARC-Authentication-Results",
|
||||||
|
"Authentication-Results",
|
||||||
|
"X-Original-Authentication-Results"
|
||||||
|
};
|
||||||
|
|
||||||
/** Options to use when serialising a message in RFC 822 format. */
|
/** Options to use when serialising a message in RFC 822 format. */
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|
@ -108,6 +113,14 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
|
||||||
public Date? date { get { return this._date; } }
|
public Date? date { get { return this._date; } }
|
||||||
private Date? _date = null;
|
private Date? _date = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* Value will be valid if {@link Field.AUTH_RESULTS} is set.
|
||||||
|
*/
|
||||||
|
public RFC822.AuthenticationResults? auth_results { get { return this._auth_results; } }
|
||||||
|
private RFC822.AuthenticationResults? _auth_results = null;
|
||||||
|
|
||||||
/** Value of the X-Mailer header. */
|
/** Value of the X-Mailer header. */
|
||||||
public string? mailer { get; protected set; default = null; }
|
public string? mailer { get; protected set; default = null; }
|
||||||
|
|
||||||
|
|
@ -160,6 +173,14 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
|
||||||
this._message_id = new MessageID(message_id);
|
this._message_id = new MessageID(message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (string field in HEADER_AUTH_RESULTS) {
|
||||||
|
var auth_results = message.get_header(field);
|
||||||
|
if (auth_results != null) {
|
||||||
|
this._auth_results = new AuthenticationResults(auth_results);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Since these headers may be specified multiple times, we
|
// Since these headers may be specified multiple times, we
|
||||||
// need to iterate over all of them to find them.
|
// need to iterate over all of them to find them.
|
||||||
var headers = message.get_header_list();
|
var headers = message.get_header_list();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue