diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 5ab3ecee4..57d622150 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -722,7 +722,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again end # e. g. Content-Type: video/quicktime - if filename.blank? + if filename.blank? && (content_type = headers_store['Content-Type']) map = { 'message/delivery-status': %w[txt delivery-status], 'text/plain': %w[txt document], @@ -734,7 +734,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again 'image/gif': %w[gif image], } 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? "#{headers_store['Content-Description']}.#{ext[0]}".to_s.force_encoding('utf-8') diff --git a/test/data/mail/mail087.box b/test/data/mail/mail087.box new file mode 100644 index 000000000..317d5c496 --- /dev/null +++ b/test/data/mail/mail087.box @@ -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 diff --git a/test/data/mail/mail087.yml b/test/data/mail/mail087.yml new file mode 100644 index 000000000..39188b1a7 --- /dev/null +++ b/test/data/mail/mail087.yml @@ -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