[geary/mjog/934-gmail-duplicate-messages: 1/4] Geary.RFC822.MessageID: Ensure RFC822 value does not include errant wtsp
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/934-gmail-duplicate-messages: 1/4] Geary.RFC822.MessageID: Ensure RFC822 value does not include errant wtsp
- Date: Sat, 22 Aug 2020 07:08:17 +0000 (UTC)
commit 4e50822674b06722ebe5f4584550f8c0f87da863
Author: Michael Gratton <mike vee net>
Date: Sat Aug 22 11:57:12 2020 +1000
Geary.RFC822.MessageID: Ensure RFC822 value does not include errant wtsp
`to_rfc822_string` must not include any leading/trailing white space
even if it was included in the `from_rfc822_string` constructor.
src/engine/rfc822/rfc822-message-data.vala | 8 +-------
test/engine/rfc822/rfc822-message-data-test.vala | 18 +++++++++++++++++-
2 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-message-data.vala b/src/engine/rfc822/rfc822-message-data.vala
index c81ac4a6a..14e41f7fe 100644
--- a/src/engine/rfc822/rfc822-message-data.vala
+++ b/src/engine/rfc822/rfc822-message-data.vala
@@ -41,8 +41,6 @@ public interface Geary.RFC822.EncodedMessageData :
public class Geary.RFC822.MessageID :
Geary.MessageData.StringMessageData, DecodedMessageData {
- private string rfc822 = null;
-
public MessageID(string value) {
base(value);
}
@@ -52,17 +50,13 @@ public class Geary.RFC822.MessageID :
throw new Error.INVALID("Empty RFC822 message id: %s", rfc822);
}
base(GMime.utils_decode_message_id(rfc822));
- this.rfc822 = rfc822;
}
/**
* Returns the {@link Date} in RFC 822 format.
*/
public string to_rfc822_string() {
- if (this.rfc822 == null) {
- this.rfc822 = "<%s>".printf(this.value);
- }
- return this.rfc822;
+ return "<%s>".printf(this.value);
}
}
diff --git a/test/engine/rfc822/rfc822-message-data-test.vala
b/test/engine/rfc822/rfc822-message-data-test.vala
index b3f5fd52d..9eeb27d9a 100644
--- a/test/engine/rfc822/rfc822-message-data-test.vala
+++ b/test/engine/rfc822/rfc822-message-data-test.vala
@@ -15,7 +15,8 @@ class Geary.RFC822.MessageDataTest : TestCase {
add_test("header_from_rfc822", header_from_rfc822);
add_test("header_names_from_rfc822", header_names_from_rfc822);
add_test("PreviewText.with_header", preview_text_with_header);
- add_test("MessageIDList.from_rfc822_string", message_id_list_from_rfc822_string);
+ add_test("MessageId.to_rfc822_string", message_id_to_rfc822_string);
+ add_test("MessageIdList.from_rfc822_string", message_id_list_from_rfc822_string);
add_test("MessageIdList.merge", message_id_list_merge);
}
@@ -110,6 +111,21 @@ class Geary.RFC822.MessageDataTest : TestCase {
assert_equal(neg_half_hour_tz.to_rfc822_string(), NEG_HALF_HOUR_TZ);
}
+ public void message_id_to_rfc822_string() throws GLib.Error {
+ assert_equal(
+ new MessageID("note_895184 gitlab gnome org").to_rfc822_string(),
+ "<note_895184 gitlab gnome org>"
+ );
+ assert_equal(
+ new MessageID.from_rfc822_string("<note_895184 gitlab gnome org>").to_rfc822_string(),
+ "<note_895184 gitlab gnome org>"
+ );
+ assert_equal(
+ new MessageID.from_rfc822_string(" <note_895184 gitlab gnome org>\n").to_rfc822_string(),
+ "<note_895184 gitlab gnome org>"
+ );
+ }
+
public void message_id_list_from_rfc822_string() throws GLib.Error {
// Standard variants
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]