mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
Implement basic IDNA support
This patch implements the first steps of support for IDNA (Internationalized Domain Names for Applications). Internally, we maintain the byte-agnostic representation, including configuration. We support receiving IDNA mail over SMTP, which we convert to unicode for internal handling. Local deliveries are still kept agnostic. For sending over SMTP, we use IDNA for DNS resolution, but there are some corner cases pending in the SMTP courier that are tied with SMTPUTF8 and will be fixed in subsequent patches.
This commit is contained in:
10
chasquid.go
10
chasquid.go
@@ -609,6 +609,11 @@ func (c *Conn) MAIL(params string) (code int, msg string) {
|
||||
if !strings.Contains(e.Address, "@") {
|
||||
return 501, "sender address must contain a domain"
|
||||
}
|
||||
|
||||
e.Address, err = envelope.IDNAToUnicode(e.Address)
|
||||
if err != nil {
|
||||
return 501, "malformed address (IDNA conversion failed)"
|
||||
}
|
||||
}
|
||||
|
||||
// Note some servers check (and fail) if we had a previous MAIL command,
|
||||
@@ -641,6 +646,11 @@ func (c *Conn) RCPT(params string) (code int, msg string) {
|
||||
return 501, "malformed address"
|
||||
}
|
||||
|
||||
e.Address, err = envelope.IDNAToUnicode(e.Address)
|
||||
if err != nil {
|
||||
return 501, "malformed address (IDNA conversion failed)"
|
||||
}
|
||||
|
||||
if c.mailFrom == "" {
|
||||
return 503, "sender not yet given"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user