-
Notifications
You must be signed in to change notification settings - Fork 366
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
📌 go-guerrilla cannot properly handle some valid addresses. #199
Comments
Personally this is the number one priority for me. I can tackle everything else as I have my own set of processors, but this……, this, unfortunately, is a job of the core, which I have zero knowledge of. I need your insight and help on this if you don’t mind. Unlike internationalized emails ( |
Thanks! The evaluation of quoted/escaped strings in the todo list #201 , so that one should be done first. TODO
|
… empty string of address is empty, or just "postmaster" it it's a postmaster address
Changes made in PR #202
|
also fixes a bugs: - emails such as "user"@test.com do not need quoting - Address.String() now outputs the IP around in braces
- Parser captures quoted local-parts without the escape characters - mail.Address.String() know when to quote local-part, - server's `allowsHost` function is ipv6 address aware (addresses specified in the config will get normalized to their ipv6 simplest form, addresses parsed from RCPT and MAIL commands will have ipv6 normalized) - if `<postmaster>` is used in the RCPT TO (without a host), then new functionality was added to assume that the host is assumed to be the Hostname setting for the Server - HELO/EHLO argument validation. #200 - The “header” processor populates “Received:” headers wrongly. #198 - tiny bug in “p_redis.go”. #196 - “MimeHeaderDecode” (envelope.go) returns an incorrectly-spaced string. #195 - go-guerrilla cannot properly handle some valid addresses. #199
go-guerrilla/mail/envelope.go
Lines 32 to 48 in 51f7dda
What this little structure can do is rather limited.
Address.String()
is and may be used in many places throughout the code (e.g. populating headers, storing into a database.), yet it sometimes screws things up; it is not reliable.Test cases
Quoted
Local-part
s ✅ VALID INPUTS(return_path).User
:[SPACE][SPACE]yo--[SPACE]man[SPACE]wazz'''up?[SPACE]surprise[SPACE]surprise,[SPACE]this[SPACE]is[SPACE][email protected][SPACE]
. ❌ INVALIDLocal-part
(return_path).Host
:example.com
.(return_path).String()
:[SPACE][SPACE]yo--[SPACE]man[SPACE]wazz'''up?[SPACE]surprise[SPACE]surprise,[SPACE]this[SPACE]is[SPACE][email protected][SPACE]@example.com
. ❌ INVALIDMailbox
address-literal
mailboxes ✅ VALID INPUTS(return_path).User
:hi
.(return_path).Host
:1.1.1.1
. ❌ INVALIDaddress-literal
(return_path).String()
:[email protected]
. ❌ INVALIDMailbox
(return_path).User
:hi
.(return_path).Host
:2001:db8::8a2e:370:7334
. ❌ INVALIDaddress-literal
; NEEDS TO BE NORMALIZED FOR CORRECT COMPARISONS.(return_path).String()
:hi@2001:db8::8a2e:370:7334
. ❌ INVALIDMailbox
(return_path).User
:hi
.(return_path).Host
:2001:DB8::8A2E:370:7334
. ❌ INVALIDaddress-literal
; NEEDS TO BE NORMALIZED FOR CORRECT COMPARISONS.(return_path).String()
:hi@2001:DB8::8A2E:370:7334
. ❌ INVALIDMailbox
Null return-path and Postmaster recipient ✅ VALID INPUTS
(return_path).IsEmpty()
:true
. ✅(return_path).String()
:@
. ❌ INVALIDMailbox
; andp_sql.go
doesn’t care about it. Would be better to make it return an empty string instead.(recipient).String()
:Postmaster@
❌ SHOULD JUST BEPostmaster
.Notes
For the
User
part" al\ph\a "@grr.la
should be" alpha "@grr.la
."alpha"@grr.la
should be[email protected]
."alp\h\a"@grr.la
should be[email protected]
.From RFC 5321:
go-guerrilla
may safely normalize it intoPostmaster
.go-guerrilla/mail/rfc5321/parse.go
Lines 96 to 99 in 51f7dda
That’s the code doing that, but what’s inconsistent there is that it only does that when it has no host part:
<posTMAstEr>
→<Postmaster>
but<[email protected]>
→<[email protected]>
. Postmaster is case-insensitive regardless of having a host. So why don’t we normalize it for the both cases? Hold on, what should we do for<"P\O\STMASTER"@example.com>
?For the
Host
partIf an
address-literal
is given, it should normalize it into bytes, and give them some appropriate brackets,[IPv6:……]
or[……]
. Such normalization also helps to resolve #197.Considerations
Local-part
: as shown above, the currentgo-guerrilla
does unquote it, but does it unescape it, too? ⸺ No, it doesn’t……."moto\y\a\s\u"
becomes justmoto\y\a\s\u
. Could we modify the parser not to accumulate the backslash, so that we can use it for the normalization steps?go-guerrilla/mail/rfc5321/parse.go
Lines 487 to 490 in 51f7dda
Local-part
has a character that is neitheratext
nor.
.\
and"
.The text was updated successfully, but these errors were encountered: