andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

Underscore replaced by space in email body #158

Open smurfpandey opened 10 years ago

smurfpandey commented 10 years ago

I noticed that all underscore characters are getting replaced by a space. We have a workflow where we are reading URL from the email body, but all URLs with underscore are broken after reading via the our app. e.g Actual URL in email:

http://en.m.wikipedia.org/wiki/Google_Web_Server

URL read by the app:

http://en.m.wikipedia.org/wiki/Google Web Server\r\n
jstedfast commented 10 years ago

The 'Q' encoding used in rfc2047 headers uses underscores to encode spaces for easier legibility. The Content-Transfer-Encoding: quoted-printable encoding does not do this and has other differences as well.

Currently the code uses Utilities.DecodeQuotedPrintable() for both cases and here's where underscores are converted to spaces:

https://github.com/andyedinborough/aenetmail/blob/master/Utilities.cs#L241

As a quick and dirty hack, you could probably modify DecodeQuotedPrintable to take a boolean arg to specify if it should decode underscores and then modify the code that uses it to pass the correct true/false value.

smurfpandey commented 10 years ago

I was aware of this function, but wasn't sure how it works. Will do a quick hack myself now.