[geary/mjog/rfc822-cleanup-part-n: 4/9] Geary.Imap.EnvelopeDecoder: Suppress message id errors
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/rfc822-cleanup-part-n: 4/9] Geary.Imap.EnvelopeDecoder: Suppress message id errors
- Date: Thu, 30 Jul 2020 03:08:57 +0000 (UTC)
commit 0b8bf7375fec3260f1309618620a5640ac742888
Author: Michael Gratton <mike vee net>
Date: Tue Jun 30 14:38:09 2020 +1000
Geary.Imap.EnvelopeDecoder: Suppress message id errors
Even if the a message has an invalid message id or message id list
header value, we need to keep parsing the message to ensure we can
do *something* useful with it.
.../imap/response/imap-fetch-data-decoder.vala | 33 ++++++++++++++++++++--
1 file changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/imap/response/imap-fetch-data-decoder.vala
b/src/engine/imap/response/imap-fetch-data-decoder.vala
index 2d3cfce6d..1c35d99ae 100644
--- a/src/engine/imap/response/imap-fetch-data-decoder.vala
+++ b/src/engine/imap/response/imap-fetch-data-decoder.vala
@@ -160,12 +160,15 @@ public class Geary.Imap.EnvelopeDecoder : Geary.Imap.FetchDataDecoder {
return new Envelope(
sent_date,
new Geary.RFC822.Subject.from_rfc822_string(subject.ascii),
- parse_addresses(from), parse_addresses(sender), parse_addresses(reply_to),
+ parse_addresses(from),
+ parse_addresses(sender),
+ parse_addresses(reply_to),
(to != null) ? parse_addresses(to) : null,
(cc != null) ? parse_addresses(cc) : null,
(bcc != null) ? parse_addresses(bcc) : null,
- (in_reply_to != null) ? new Geary.RFC822.MessageIDList.from_rfc822_string(in_reply_to.ascii) :
null,
- (message_id != null) ? new Geary.RFC822.MessageID(message_id.ascii) : null);
+ (in_reply_to != null) ? new_message_id_list(in_reply_to.ascii) : null,
+ (message_id != null) ? new_message_id(message_id.ascii) : null
+ );
}
// TODO: This doesn't handle group lists (see Johnson, p.268) -- this will throw an
@@ -189,6 +192,30 @@ public class Geary.Imap.EnvelopeDecoder : Geary.Imap.FetchDataDecoder {
return new Geary.RFC822.MailboxAddresses(list);
}
+
+ private RFC822.MessageID? new_message_id(string? rfc822) {
+ RFC822.MessageID? id = null;
+ if (!String.is_empty_or_whitespace(rfc822)) {
+ try {
+ id = new RFC822.MessageID.from_rfc822_string(rfc822);
+ } catch (RFC822.Error err) {
+ debug("Failed to parse message id: %s", err.message);
+ }
+ }
+ return id;
+ }
+
+ private RFC822.MessageIDList? new_message_id_list(string? rfc822) {
+ RFC822.MessageIDList? list = null;
+ if (!String.is_empty_or_whitespace(rfc822)) {
+ try {
+ list = new RFC822.MessageIDList.from_rfc822_string(rfc822);
+ } catch (RFC822.Error err) {
+ debug("Failed to parse message id list: %s", err.message);
+ }
+ }
+ return list;
+ }
}
public class Geary.Imap.RFC822HeaderDecoder : Geary.Imap.FetchDataDecoder {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]