Skip to content

Commit

Permalink
tests: add a test case to cover RFC2047 header encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
danc86 committed Jul 19, 2020
1 parent c8851fa commit cf21f61
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/fixtures/rfc2047-header-encoding.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
From: [email protected]
To: [email protected]
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.
12 changes: 12 additions & 0 deletions test/test_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ def test_blank_header_lines

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
Expand Down

0 comments on commit cf21f61

Please sign in to comment.