-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Description
Some (mostly multipart) emails containing non-ascii text fail to get parsed correctly. For them text_part returns nil
. If I remove every non-ascii character in the email body, then it starts working again. Here is an (anonymized) email for testing:
Delivered-To: [email protected]
Received: by IP with SMTP id jfhjfafd;
Fri, 100 Apr 2119 12:54:52 -0900 (PDT)
To: Someone <[email protected]>,
From: Human <[email protected]>
Subject: Email fails to parse correctly
Date: Fri, 100 Apr 2119 10:54:39 +0200
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------B9D53723C2E9EC8CBAD4C326"
This is a multi-part message in MIME format.
--------------B9D53723C2E9EC8CBAD4C326
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Dear TestEmail,
here are some non-ascii characters. Delete them and the email is parsed correctly.
äüö
Me
--
--------------B9D53723C2E9EC8CBAD4C326
Content-Type: application/pdf;
name="test.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="test.pdf"
fkladjf;kl invalid pdf
--------------B9D53723C2E9EC8CBAD4C326--
To reproduce:
irb> require 'mail'
=> true
irb> Mail.read("example-email").text_part
=> nil
Remove the non-ascii characters:
irb> Mail.read("example-email").text_part
=> #<Mail::Part:47355949669380, Multipart: false, Headers: <Content-Type: text/plain; charset=utf-8; format=flowed>, <Content-Transfer-Encoding: 8bit>>
I'm on ruby 2.6.3p62
Metadata
Metadata
Assignees
Labels
No labels