Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail doesn't parse parts if plain/text contain ’ symbol #1315

Closed
iggant opened this issue Feb 11, 2019 · 2 comments
Closed

Mail doesn't parse parts if plain/text contain ’ symbol #1315

iggant opened this issue Feb 11, 2019 · 2 comments

Comments

@iggant
Copy link

iggant commented Feb 11, 2019

create email file mail.msg

MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="=_081e3772855208a6e4fd5e0fc0226ac6"
Date: Wed, 06 Feb 2019 11:40:26 -0500
From: Some Person <person@example.com>
To: Other Person <person@example.com>
Subject: Re: question [Thread: goUYOWlr.1]
User-Agent: Roundcube Webmail/1.3.8

--=_081e3772855208a6e4fd5e0fc0226ac6
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

FIRSTNAME O’LASTNAME, CPA
--=_081e3772855208a6e4fd5e0fc0226ac6
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<div><strong>FIRSTNAME O&rsquo;LASTNAME, CPA </strong></div>

--=_081e3772855208a6e4fd5e0fc0226ac6--

create example file:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'mail'
end


file = File.open('mail.msg')
email = Mail.read(file)
puts email.parts.inspect

Actual output:
[#<Mail::Part:47308565129460, Multipart: false, Headers: <Content-Type: text/plain; charset=UTF-8>, <Content-Transfer-Encoding: 8bit>>]

Expected output:

[#<Mail::Part:47220814372500, Multipart: false, Headers: <Content-Type: text/plain; charset=UTF-8>, <Content-Transfer-Encoding: 8bit>>, #<Mail::Part:47220814403800, Multipart: false, Headers: <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: quoted-printable>>]

Due to ’ in the text/plain part of the mail, gem doesn't parse email correctly

@jeremy
Copy link
Collaborator

jeremy commented Feb 11, 2019

It's because the email has LF line endings, not CRLF, and we can't detect that it's safe to automatically convert them LF → CRLF.

Highly recommend switching to CRLF line endings if you can. This mostly affects test fixtures that have been saved with UNIX line endings (\n) instead of DOS line endings (\r\n). CRLF is required, but Mail has long attempted to support LF for convenience. But that results in sometimes mangling binary values, no good.

See #1159 and #1160 for more.

@jeremy jeremy closed this as completed Feb 11, 2019
@iggant
Copy link
Author

iggant commented Feb 13, 2019

@jeremy but the problem is that we are not in charge of this email, this is real email from postfix, that we have to parse and process ((

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants