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

Incorrect decode UTF-8 encoded mail address #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cshrper
Copy link

@cshrper cshrper commented Mar 16, 2016

bug occurs when I load Message from ".eml" file, that has been created some other program,
and it has the MailAddress encoded in UTF-8,
for example:
I got decoded value "Лучшему кл��енту [email protected]"
instead of "Лучшему клиенту [email protected]"

you can test old version with headers:
X-Sender: =?utf-8?Q?=D0=A3=D0=B2=D0=B0=D0=B6=D0=B0=D0=B5=D0=BC=D1=8B=D0?=
=?utf-8?Q?=B9_=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA?=
[email protected]
X-Receiver: =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=BA?=
=?utf-8?Q?=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D1=83?= [email protected]
X-Receiver: =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=B4?=
=?utf-8?Q?=D1=80=D1=83=D0=B3=D1=83_=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0?=
=?utf-8?Q?=B3=D0=BE_=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?=
[email protected]
MIME-Version: 1.0
From: =?utf-8?Q?=D0=A3=D0=B2=D0=B0=D0=B6=D0=B0=D0=B5=D0=BC=D1=8B=D0=B9?=
=?utf-8?Q?=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA?=
[email protected]
To: =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83
=D0=BA=D0=BB=D0?=
=?utf-8?Q?=B8=D0=B5=D0=BD=D1=82=D1=83?= [email protected],
=?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=B4=D1=80=D1?=
=?utf-8?Q?=83=D0=B3=D1=83_=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=B3=D0=BE?=
=?utf-8?Q?_=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?= [email protected]

cshrper added 2 commits March 16, 2016 19:50
bug occurs when I load Message from ".eml" file, that has been created some other program,
and it has the MailAddress encoded in UTF-8,
for example: 
I got decoded value "Лучшему кл��енту <[email protected]>"
instead of "Лучшему клиенту <[email protected]>"

you can test old version with headers:
X-Sender: =?utf-8?Q?=D0=A3=D0=B2=D0=B0=D0=B6=D0=B0=D0=B5=D0=BC=D1=8B=D0?=
 =?utf-8?Q?=B9_=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA?=
 <[email protected]>
X-Receiver: =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=BA?=
 =?utf-8?Q?=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D1=83?= <[email protected]>
X-Receiver: =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=B4?=
 =?utf-8?Q?=D1=80=D1=83=D0=B3=D1=83_=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0?=
 =?utf-8?Q?=B3=D0=BE_=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?=
 <[email protected]>
MIME-Version: 1.0
From: =?utf-8?Q?=D0=A3=D0=B2=D0=B0=D0=B6=D0=B0=D0=B5=D0=BC=D1=8B=D0=B9?=
 =?utf-8?Q?_=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA?=
 <[email protected]>
To: =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=BA=D0=BB=D0?=
 =?utf-8?Q?=B8=D0=B5=D0=BD=D1=82=D1=83?= <[email protected]>,
 =?utf-8?Q?=D0=9B=D1=83=D1=87=D1=88=D0=B5=D0=BC=D1=83_=D0=B4=D1=80=D1?=
 =?utf-8?Q?=83=D0=B3=D1=83_=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=B3=D0=BE?=
 =?utf-8?Q?_=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?= <[email protected]>
@cshrper cshrper changed the title Update EncodedWord.cs Incorrect decode UTF-8 encoded mail address Mar 16, 2016
@foens
Copy link
Owner

foens commented Mar 19, 2016

Hello and thank you for your pull request. Is it possible that you could change the indentation to tabs and add a test case such that that this bug will not be reintroduced again? Then I would merge the pull request.

@cshrper
Copy link
Author

cshrper commented Mar 20, 2016

No, I do not change any thing. I just do so:
var to = new MailAddress("[email protected]", "Лучшему клиенту");
var from = new MailAddress("[email protected]", "Уважаемый поставщик");
var message = new MailMessage(from, to);
message.To.Add(new MailAddress("[email protected]", "Лучшему другу лучшего клиента"));
message.Subject = "Используем новый SMTP клиент.";
message.SubjectEncoding = Encoding.UTF8;

message.Body = "Using this new feature, you can send an e-mail message from an application very easily.";
message.BodyEncoding = Encoding.UTF8;
var smtpClient = new System.Net.Mail.SmtpClient { DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory };
smtpClient.PickupDirectoryLocation = tempDir.DirectoryPath;
smtpClient.Send(message);

And then I try to load message:
var msg = OpenPop.Mime.Message.Load(new FileInfo(Path.Combine(path, "Test.eml")));

@jstedfast
Copy link

This patch is broken. The patch assumes that each encoded word token uses the exact same encoding and charset values, but neither are guaranteed to be the case.

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

Successfully merging this pull request may close these issues.

3 participants