1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

Convert addresses to lower case

This patch makes the MAIL FROM and RCPT TO commands convert addresses to lower
case. It also makes the commands themselves case-flexible as a side effect.
This commit is contained in:
Alberto Bertogli
2015-11-06 03:46:13 +00:00
parent fbf1060b71
commit e5c2676f83

View File

@@ -380,8 +380,8 @@ func (c *Conn) NOOP(params string) (code int, msg string) {
func (c *Conn) MAIL(params string) (code int, msg string) { func (c *Conn) MAIL(params string) (code int, msg string) {
// params should be: "FROM:<name@host>" // params should be: "FROM:<name@host>"
// First, get rid of the "FROM:" part (but check it, it's mandatory). // First, get rid of the "FROM:" part (but check it, it's mandatory).
sp := strings.SplitN(params, ":", 2) sp := strings.SplitN(strings.ToLower(params), ":", 2)
if len(sp) != 2 || sp[0] != "FROM" { if len(sp) != 2 || sp[0] != "from" {
return 500, "unknown command" return 500, "unknown command"
} }
@@ -415,8 +415,8 @@ func (c *Conn) MAIL(params string) (code int, msg string) {
func (c *Conn) RCPT(params string) (code int, msg string) { func (c *Conn) RCPT(params string) (code int, msg string) {
// params should be: "TO:<name@host>" // params should be: "TO:<name@host>"
// First, get rid of the "TO:" part (but check it, it's mandatory). // First, get rid of the "TO:" part (but check it, it's mandatory).
sp := strings.SplitN(params, ":", 2) sp := strings.SplitN(strings.ToLower(params), ":", 2)
if len(sp) != 2 || sp[0] != "TO" { if len(sp) != 2 || sp[0] != "to" {
return 500, "unknown command" return 500, "unknown command"
} }