commit b1a3e7f8f16d375192ae59b0c1ddf65fb901fe9e
parent a3b77fd720963dbdaf99c7b5611c64c6f49ad665
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 19 Jul 2020 17:33:06 +1000
tests: add a test case to cover RFC2047 header encoding
Diffstat:
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/test/fixtures/rfc2047-header-encoding.eml b/test/fixtures/rfc2047-header-encoding.eml
@@ -0,0 +1,11 @@
+From: test@example.invalid
+To: test@example.invalid
+Date: Sun, 19 Jul 2020 17:03:56 +1000
+Subject:
+ =?US-ASCII?q?Hans_Martin_Djupvik?= =?ISO-8859-1?q?,_Ingrid_B=F8?=
+ =?KOI8-R?b?LCDp0snOwSDzycTP0s/XwQ?=
+ =?UTF-16?b?//4sACAASgBlAHMAcABlAHIAIABCAGUAcgBnAA?=
+
+The subject header contains various RFC2047 encoded words.
+For completeness we test both base64 and quoted-printable, and some
+ASCII-incompatible encodings.
diff --git a/test/test_message.rb b/test/test_message.rb
@@ -232,6 +232,18 @@ class TestMessage < Minitest::Test
end
+ def test_rfc2047_header_encoding
+ source = DummySource.new("sup-test://test_rfc2047_header_encoding")
+ source.messages = [ fixture_path("rfc2047-header-encoding.eml") ]
+ source_info = 0
+
+ sup_message = Message.build_from_source(source, source_info)
+ sup_message.load_from_source!
+
+ assert_equal("Hans Martin Djupvik, Ingrid Bø, Ирина Сидорова, Jesper Berg",
+ sup_message.subj)
+ end
+
def test_nonascii_header
## Headers are supposed to be 7-bit ASCII, with non-ASCII characters encoded
## using RFC2047 header encoding. But spammers sometimes send high bytes in