Skip to content

x/inet/idna: ToAscii doesn't reject hyphens in positions 3 & 4 when 1 & 2 aren't ascii #81026

Description

@hnakamur

Go version

go version go1.27.0 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/hnakamur/go/bin'
GOCACHE='/home/hnakamur/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/hnakamur/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build179634315=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/hnakamur/ghq/github.com/golang/net/go.mod'
GOMODCACHE='/home/hnakamur/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPACKAGESDRIVER=''
GOPATH='/home/hnakamur/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/hnakamur/.local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/hnakamur/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/hnakamur/.local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.27.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I called idna.Lookup.ToASCII with a string such as "大阪--府.jp", where the first two characters are non-ASCII and the third and fourth characters are hyphens.

https://go.dev/play/p/F5r4Yy8V7qL

What did you see happen?

It prints the converted ASCII domain xn-----ku9c20sw31f.jp.

What did you expect to see?

It prints the error idna: invalid label "大阪--府".

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions