Skip to content

net/mail: ParseAddress doesn't support using a domain-literal in the domain of an email address #60206

@robplee

Description

@robplee

What version of Go are you using (go version)?

$ go version
go version go1.19.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes, confirmed against 1.20 and "Go dev branch" using The Go Playground

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/robertlee/Library/Caches/go-build"
GOENV="/Users/robertlee/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/robertlee/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/robertlee/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/robertlee/go/src/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/g9/kjpfy6dn3f3gr60k0j5f5j9r0000gn/T/go-build2238133857=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I used mail.ParseAddress to try to parse an email address containing an IP address.

package main

import (
	"fmt"
	"net/mail"
)

func main() {
	_, err := mail.ParseAddress("me@[192.168.0.1]")
	if err != nil {
		fmt.Println("mail is complaining incorrectly")
	}
}

Go playground: https://go.dev/play/p/rZW6QPqVZC6

What did you expect to see?

mail.ParseAddress shouldn't have returned an error and the program should not have printed any output

This format, me@[192.168.0.1], is how email addresses are supposed to be formatted according to Section 3.4.1 of RFC 5322, so this email address should have been parsed correctly without any error being returned.

What did you see instead?

mail.Parse address did return an error so the message "mail is complaining incorrectly" was printed

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions