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: Read() returns error when underlying string ends with soft-break ("=") #15486

Closed
jspy opened this issue Apr 29, 2016 · 3 comments
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jspy
Copy link

jspy commented Apr 29, 2016

go1.6.1 linux/amd64

https://play.golang.org/p/j9BAuXothm

The implementation of Read() in mime/quotedprintable/reader.go returns an error when the underlying string ends with an equals character ("="), indicating a soft-break:

quotedprintable: invalid bytes after =: ""

If I remove the last "=", it works great.

I am not familiar with all the details of RFC 2045, but I interpret point 3 on page 22 in the standard to say that the Go implementation technically is correct. But, as it says in point 2 on the same page, it would be more robust to accept it. Also note that these strings occur in the wild; the software that produced this particular string is:

X-Mailer: Apple Mail (2.3124)

I also take this into account (from mime/quotedprintable/reader.go, lines 73-76:
// Deviations from RFC 2045:
// 1. in addition to "=\r\n", "=\n" is also treated as soft line break.
// 2. it will pass through a '\r' or '\n' not preceded by '=', consistent
// with other broken QP encoders & decoders.

I would love it if Go was practical enough to add a point "3. it will pass though EoB preceeded by '=' due to broken QP encoders" as that will save a lot of edge cases and extra code further up the chain, but I understand If you disagree.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Apr 29, 2016
@minaevmike
Copy link
Contributor

Hi!
I have same problems. By the way a lot of programs for handling mails do this stuff, e.g. Evolution. My current "bad" solution is

        r := quotedprintable.NewReader(strings.NewReader(buf))
    b, err := ioutil.ReadAll(r)
    if err != nil && len(b) == 0 {
        log.Fatal(err)
    }

So do you have any plans to fix it?

@bradfitz bradfitz modified the milestones: Go1.8Maybe, Unplanned Aug 22, 2016
@bradfitz bradfitz added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 22, 2016
@bradfitz
Copy link
Contributor

/cc @alexcesaro @minux

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants