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

mime/quotedprintable: accept invalid quoted-printable as unquoted #13219

Closed
cention-sany opened this issue Nov 12, 2015 · 6 comments
Closed

mime/quotedprintable: accept invalid quoted-printable as unquoted #13219

cention-sany opened this issue Nov 12, 2015 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cention-sany
Copy link

golang version: 1.5.1

There are some emails use the equal sign in-appropriately without escape it with =3D. This will make golang library fail to parse this kind of email. But some mail clients such as Thunderbird able can parse these malformed emails.

If this line change to break then more emails can be successfully parsed. Or return certain error which indicate it is safe to bypass it.

@bradfitz
Copy link
Contributor

Please provide a sample of such an invalid input.

@bradfitz bradfitz changed the title relaxing quoted-printable parser for higher success rate on parsing bad email mime/quotedprintable: relaxing quoted-printable parser for higher success rate on parsing bad email Nov 12, 2015
@cention-sany
Copy link
Author

Attached. This attachment (was *.eml) can be opened with Thunderbird but when parse through Golang, will give the error: quotedprintable: invalid hex byte 0x22

string as below will fail.
<P><p><font face="Arial, Helvetica, sans-serif" size="2" style="font-size:13.5px">

sample.txt

@rsc
Copy link
Contributor

rsc commented Dec 28, 2015

Relevant bits below. Looks like "Microsoft CDO for Exchange 2000" basically just lies about quoted printable.

MIME-Version: 1.0
X-Mailer: Microsoft CDO for Exchange 2000
Importance: Normal
Priority: normal
Content-Class: urn:content-classes:message
Content-Type: multipart/alternative;
    boundary="----=_NextPart_000_6A3C_01D11B6E.BC80DF90"

This is a multi-part message in MIME format.

------=_NextPart_000_6A3C_01D11B6E.BC80DF90
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
    charset="iso-8859-1"

<P><p><font face="Arial, Helvetica, sans-serif" size="2" style="font-size:13.5px">
------=_NextPart_000_6A3C_01D11B6E.BC80DF90
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html

<HTML>
<BODY>
<DIV><br>
Hej igen!</DIV>
</BODY></HTML
------=_NextPart_000_6A3C_01D11B6E.BC80DF90--

@rsc rsc changed the title mime/quotedprintable: relaxing quoted-printable parser for higher success rate on parsing bad email mime/quotedprintable: accept invalid quoted-printable as unquoted Dec 28, 2015
@rsc rsc added this to the Go1.7 milestone Dec 28, 2015
@cention-sany
Copy link
Author

I encountered another bad email which need these lines to be commented out too.

In fact, I noticed many of Golang stdlib (mostly on email parsing as I am using these frequently) return error once they encounter error and do not try whether it can do something else. I reported once which was closed #13448. After that actually I found there are many of them too. Another example will be this, why must return? why not finish all first? and return everything that you find good as well as the error - some special error to indicate there are still some useful data. User of this library can then decide whether to ignore the error or not and take whatever good.

I understand this is not some kind error but the fact is the Golang stdlib returning nil or insufficient data once it encounters error (some avoidable or recoverable errors) forced me to move away from stdlib because the need to create compatible email client as Thunderbird using Golang. Still, I believe Golang can do better.

@ianlancetaylor
Copy link
Contributor

@cention-sany This specific issue is not the place to discuss the general handling of format errors in the Go standard library. That is appropriate for the golang-dev mailing list.

@rsc rsc modified the milestones: Go1.8, Go1.7 May 18, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 7, 2016
@gopherbot
Copy link

CL https://golang.org/cl/32174 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants