Errors in address format processing without white space
rudyeeee opened this issue · comments
What I did:
...
From: "=?UTF-8?B?7ZWc6rWt642w7J207YSw7KeE7Z2l7JuQ?="<kodb_pr@kdata.or.kr>
...
The following problem occurred during testing with the eml file containing the above sender.
When testing with the same data,
using the mail package's mail.ParseAddressList(m.GetHeader("From")) works correctly,
but when using Envelope.AddressList("From"), a mail: no angle-addr error occurs.
What I expected:
([]*Mail.Address) returned without error,
What I got:
returned error
mail: no angle-addr
Release or branch I am using:
both v0.5.0 and master
(Please attach a sample message if you feel it will help reproduce the issue)
The address part(<kodb_pr@kdata.or.kr>) disappears after passing through decodeToUTF8Base64Header() in AddressList().
If the while space rune does not exist between the name part and the address part, the problem seems to occur.
// original
fmt.Println(decodeToUTF8Base64Header("\"=?UTF-8?B?7ZWc6rWt642w7J207YSw7KeE7Z2l7JuQ?=\"<kodb_pr@kdata.or.kr>"))
-> =?UTF-8?b?Iu2VnOq1reuNsOydtO2EsOynhO2dpeybkCI8a29kYl9wckBrZGF0YS5vci5r?= =?UTF-8?b?cj4=?=
// Including white space
fmt.Println(decodeToUTF8Base64Header("\"=?UTF-8?B?7ZWc6rWt642w7J207YSw7KeE7Z2l7JuQ?=\" <kodb_pr@kdata.or.kr>"))
-> =?UTF-8?b?Iu2VnOq1reuNsOydtO2EsOynhO2dpeybkCI=?= <kodb_pr@kdata.or.kr>
Thanks, definitely sounds like a bug. Or at least too strict application of RFC
If easy, we may also want to add a warning to the Errors list. Not essential.
Just wanted to provide some feedback on this issue. Since this issue was raise for a quoted RFC2047 base64 encoded display name, I was able to provide a break fix. If the it was not a quoted RFC2047 base64 encoded display name, then we would need to refactor the decodeToUTF8Base64Header
completely:
- Currently we depend on the whiteSpaceRune separator for splitting the header into tokens.
- The stdlib iterates through the string, rune-by-rune, with a switch case to determine the beginning and end of each token. When it expects a whitespace,
strings.TrimLeft(s, " \t")
gets run, then proceeds to ingest the next expected token.
Should we go the route of the stdlib, I will need to call on @dcormier for his experience with rune-based iteration tokenizers
@derktam Could you please confirm if your issue is now resolved using the latest develop branch?
As a result of testing with develop branch,
It seems to have been resolved. Thank you :)
👍