Commit f28b3b88 authored by ng's avatar ng

Close #334 - test mails with broken header encoding

The mail gem below 2.7.0 is not able to handle emails with broken
charset encoding in headers.

This is an issue that must be fixed in the mail gem, but we are
adding a test to document this and be sure to not have regressions
with future versions of mail.
parent d81e0996
Pipeline #13175 passed with stages
in 43 minutes and 3 seconds
......@@ -12,6 +12,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Do not anymore fail on emails containing any PGP boundaries as part of their plain text. As a sideeffect we will not anymore validate an email a second time. Hence, a message part containing an additional signature within an encrypted (and possibly signed) email won't be validated and removed. (#261)
* Exit with code 1 if a CLI-subcommand was not found (#339).
### Known issues
* With the current used mail library version schleuder uses, there are certain malformed emails that can't be parsed. See #334 for background. This will be fixed in future releases of the mail library.
### Changed
......
Return-Path: <le.savoirmagnetisme@gmail.com>
Delivered-To: example@example.org
Received: from mail.example.org (mail.example.org [192.168.1.2])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by trebuchet.example.org (Postfix) with ESMTPS id 2C8A1A0403
for <example@example.org>; Sat, 10 Mar 2018 02:52:58 +0100 (CET)
Received: from [127.0.0.1] (localhost [127.0.0.1])example.org (mx.example.org [192.168.1.1])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mail.example.org (Postfix) with ESMTPS id 7FB4610F
for <example@example.org>; Sat, 10 Mar 2018 02:52:57 +0100 (CET)
Received: from [127.0.0.1] (localhost [127.0.0.1])ng TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mx2.example.org (Postfix) with ESMTPS id DA6D2880A0
for <example@example.org>; Sat, 10 Mar 2018 02:52:54 +0100 (CET)
Received: from [127.0.0.1] (localhost [127.0.0.1])novol420-pc (unknown [192.168.1.3])
by smtp1-g21.free.fr (Postfix) with SMTP id 95E05B0051B
for <example@example.org>; Sat, 10 Mar 2018 02:52:51 +0100 (CET)
Message-ID: <afccb596bc81341399153df738c8788c@gmail.com>
From: "Invitation" <le.savoirmagnetisme@gmail.com>
To: <example@example.org>
Subject: =?windows-1258?B?c29pcull?=
Date: Sat, 10 Mar 2018 02:52:36 +0100
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=MailPart0000_0010_0A37C499"
This is a multi-part message in MIME format.
------=MailPart0000_0010_0A37C499
Content-Type: text/plain;
charset="windows-1258"
Content-Transfer-Encoding: quoted-printable
=20
=20
------=MailPart0000_0010_0A37C499--
......@@ -395,6 +395,28 @@ describe Schleuder::Runner do
teardown_list_and_mailer(list)
end
it 'does not throw an error on emails with broken utf-8' do
list = create(:list, send_encrypted_only: false)
list.subscribe("admin@example.org", nil, true)
mail = File.read('spec/fixtures/mails/broken_utf8_charset.eml')
# From mail 2.7.0 this is handled correctly
# See #334 for background
if Gem::Version.new(Mail::VERSION.version) < Gem::Version.new('2.7.0')
expect{
Schleuder::Runner.new().run(mail, list.email)
}.to raise_error(ArgumentError)
else
Schleuder::Runner.new().run(mail, list.email)
message = Mail::TestMailer.deliveries.first
output = process_mail(message.to_s, list.email)
expect(output).to be nil
end
teardown_list_and_mailer(list)
end
end
context 'after keyword parsing' do
it 'falls back to default charset per RFC if none is set' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment