-
Notifications
You must be signed in to change notification settings - Fork 18k
mime: cannot round-trip Word{En,De}coder #14608
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
Comments
CC @alexcesaro. |
Thanks for filing this. Honestly, my preference would be for a 3rd way - if the word is not encoded, just return it.. that would mirror what WordEncoder does, and would be what I would expect to work. But I think that may not be possible with the backwards compatibility guarantee. Barring that, an IsEncoded function would be a nice alternate, so I could know if I need to try to Decode at all. The problem with calling it CanDecode is that if it returns false, I wonder if it actually is encoded, but incorrectly or something. IsEncoded is more clear, IMO. Obviously, it may still be encoded in some way that the Decoder doesn't understand, but as far as the Decoder is concerned, that's still "not encoded". |
I'm fine with options 1, 2 or 3, actually. |
I'm on holidays with a slow wifi but if I remember correctly The documentation might need some clarification.
|
I'm closing this based on @alexcesaro's comment. @natefinch, please re-open if his suggestion doesn't work for you. |
WordEncoder sometimes passes text straight through, sometimes it does not. From the example_test.go:
prints
The problem is that, given an arbitrary output of a WordEncoder, how should a user tell whether or not to pass it to a WordDecoder to recover the original? A WD returns an error if the input isn't actually escaped:
prints
RFC 2047 actually says that
Generally, an "encoded-word" is a sequence of printable ASCII characters that begins with "=?", ends with "?=", and has two "?"s in between
and, as a workaround, users of the mime package can check that before calling Decode.Still, this should probably be provided by the library, instead of users of that library. I can think of two possible solutions:
@bradfitz, WDYT?
The text was updated successfully, but these errors were encountered: