1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

Normalize local usernames using PRECIS

This patch implements local username normalization using PRECIS
(https://tools.ietf.org/html/rfc7564,
https://tools.ietf.org/html/rfc7613)

It makes chasquid accept local email and authentication regardless of
the case. It covers both userdb and aliases.

Note that non-local usernames remain untouched.
This commit is contained in:
Alberto Bertogli
2016-10-09 13:18:19 +01:00
parent 220b5d20ff
commit ad25706d72
8 changed files with 148 additions and 43 deletions

View File

@@ -25,6 +25,7 @@ import (
"blitiri.com.ar/go/chasquid/internal/config"
"blitiri.com.ar/go/chasquid/internal/courier"
"blitiri.com.ar/go/chasquid/internal/envelope"
"blitiri.com.ar/go/chasquid/internal/normalize"
"blitiri.com.ar/go/chasquid/internal/queue"
"blitiri.com.ar/go/chasquid/internal/set"
"blitiri.com.ar/go/chasquid/internal/spf"
@@ -738,8 +739,15 @@ func (c *Conn) RCPT(params string) (code int, msg string) {
return 503, "relay not allowed"
}
if localDst && !c.userExists(addr) {
return 550, "recipient unknown, please check the address for typos"
if localDst {
addr, err = normalize.Addr(addr)
if err != nil {
return 550, "recipient invalid, please check the address for typos"
}
if !c.userExists(addr) {
return 550, "recipient unknown, please check the address for typos"
}
}
c.rcptTo = append(c.rcptTo, addr)