[geary/gnumdk/stable: 8/21] Geary.RFC822.Message: Add support for Authentication-Results field
- From: Cédric Bellegarde <cbellegarde src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/gnumdk/stable: 8/21] Geary.RFC822.Message: Add support for Authentication-Results field
- Date: Mon, 1 Aug 2022 12:45:46 +0000 (UTC)
commit 0d2300fa8e533d3de16407603bcab42362062b2b
Author: Cédric Bellegarde <cedric bellegarde adishatz org>
Date: Thu Jul 7 22:13:16 2022 +0200
Geary.RFC822.Message: Add support for Authentication-Results field
src/engine/rfc822/rfc822-message-data.vala | 22 ++++++++++++++++++++++
src/engine/rfc822/rfc822-message.vala | 21 +++++++++++++++++++++
2 files changed, 43 insertions(+)
---
diff --git a/src/engine/rfc822/rfc822-message-data.vala b/src/engine/rfc822/rfc822-message-data.vala
index d36e57a0d..53cc8ac91 100644
--- a/src/engine/rfc822/rfc822-message-data.vala
+++ b/src/engine/rfc822/rfc822-message-data.vala
@@ -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);
+ }
+}
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index 521058dea..112370239 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -36,6 +36,11 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
private const string HEADER_REFERENCES = "References";
private const string HEADER_MAILER = "X-Mailer";
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. */
[Flags]
@@ -108,6 +113,14 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet {
public Date? date { get { return this._date; } }
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. */
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);
}
+ 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
// need to iterate over all of them to find them.
var headers = message.get_header_list();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]