Fixes issue #2906 - Missing Content-Type header of parsed email fails processing.

This commit is contained in:
Mantas Masalskis 2020-01-27 10:07:55 +01:00 committed by Thorsten Eckel
parent fa2ff2138b
commit b294708ec0
3 changed files with 53 additions and 2 deletions

View file

@ -722,7 +722,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
end end
# e. g. Content-Type: video/quicktime # e. g. Content-Type: video/quicktime
if filename.blank? if filename.blank? && (content_type = headers_store['Content-Type'])
map = { map = {
'message/delivery-status': %w[txt delivery-status], 'message/delivery-status': %w[txt delivery-status],
'text/plain': %w[txt document], 'text/plain': %w[txt document],
@ -734,7 +734,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
'image/gif': %w[gif image], 'image/gif': %w[gif image],
} }
map.each do |type, ext| map.each do |type, ext|
next if !headers_store['Content-Type'].match?(/^#{Regexp.quote(type)}/i) next if !content_type.match?(/^#{Regexp.quote(type)}/i)
filename = if headers_store['Content-Description'].present? filename = if headers_store['Content-Description'].present?
"#{headers_store['Content-Description']}.#{ext[0]}".to_s.force_encoding('utf-8') "#{headers_store['Content-Description']}.#{ext[0]}".to_s.force_encoding('utf-8')

View file

@ -0,0 +1,27 @@
To: support@example.com
Subject: Failed Mail
From: Test test@example.com
Content-Type: multipart/mixed; boundary=earendil
Message-Id: 20200123143934.05D7EE792E@example.com
Date: Thu, 23 Jan 2020 15:39:33 +0100 (CET)
MIME-Version: 1.0
--earendil
Content-Disposition: attachment; filename=fax_1234.pdf
Content-Type: application/pdf; name=fax_+491234.pdf
Content-Transfer-Encoding: base64
JVBERi0xLjEgCiXi48/TCjEgMCBvYmoKPDwgCi9UeXBlIC9DYXRhbG9nIAovUGFnZXMgMyAwIFIg
NjYzMzQ4NzM+XQo+PgpzdGFydHhyZWYKNDM4MjAzCiUlRU9GCg==
--earendil
Content-Transfer-Encoding: quoted-printable
Sehr geehrter Kunde,
Sie haben soeben ein neues Fax von +491234, fuer Rufnummer 01234=
7 empfangen.
Empfangszeit: Thursday, January 23 2020, at 03:39 PM
Absender: +491234
Empfaenger: 01234

View file

@ -0,0 +1,24 @@
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
from: Test test@example.com
from_email: Test test@example.com
from_display_name: Test test@example.com
to: support@example.com
subject: Failed Mail
body: no visible content
content_type: text/plain
attachments:
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
data: !binary |-
JVBERi0xLjEgCiXi48/TCjEgMCBvYmoKPDwgCi9UeXBlIC9DYXRhbG9nIAovUGFnZXMgMyAwIFIgNjYzMzQ4NzM+XQo+PgpzdGFydHhyZWYKNDM4MjAzCiUlRU9GCg==
filename: fax_1234.pdf
preferences: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
Content-Type: application/pdf; name=fax_+491234.pdf
Mime-Type: application/pdf
Charset: UTF-8
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
data: "Sehr geehrter Kunde,\r\n\r\nSie haben soeben ein neues Fax von +491234, fuer
Rufnummer 012347 empfangen.\r\n\r\nEmpfangszeit: Thursday, January 23 2020, at
03:39 PM\r\nAbsender: +491234\r\nEmpfaenger: 01234\r\n"
filename: file
preferences: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
Charset: UTF-8