Skip to content

x/net/idna: backward compatibility issues with recent change #18567

@weppos

Description

@weppos

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

go version go1.7.3 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/weppos/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rk/llwxtd9s6jn91p2ky13tr30c0000gn/T/go-build321981550=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

It looks like golang/net@67957fd (change 34770) broke backward compatibility. Given the commit message says otherwise, I'm filing this as a bug.

There are at least 2 strings that are current causing failures:

  • the empty string
  • a string starting with a leading *

I detailed the issue at weppos/publicsuffix-go#56, along with some code to reproduce it.

Here's the simplest example:

package main

import (
	"fmt"
	"os"

	"golang.org/x/net/idna"
)

func main() {
	s, err := idna.ToASCII("")
	if err != nil {
		fmt.Printf("Error converting empty string: %v\n", err)
		os.Exit(1)
	}

	fmt.Println("Empty string works!")
	fmt.Printf("Result: `%v`\n", s)
}

and here's the log

➜  publicsuffix-go git:(master) ✗ cd ~/go/src/golang.org/x/net/idna; git co 69d4b8; cd -; go run idna-test.go
Note: checking out '69d4b8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 69d4b8a... http2: remove unnecessary TODO for trailer keys allocation
~/go/src/github.com/weppos/publicsuffix-go
Empty string works!
Result: ``

➜  publicsuffix-go git:(master) ✗ cd ~/go/src/golang.org/x/net/idna; git co 67957f; cd -; go run idna-test.go
Previous HEAD position was 69d4b8a... http2: remove unnecessary TODO for trailer keys allocation
HEAD is now at 67957fd... idna: use code generated by internal x/text package
~/go/src/github.com/weppos/publicsuffix-go
Error converting empty string: idna: invalid label ""
exit status 1

What did you expect to see?

I'd expect the following string conversion:

String "" converts into "" with no errors
String "*.uk" converts into "*uk" with no errors

What did you see instead?

The empty string fails with error idna: invalid label "".
The string "*.uk" fails with error idna: disallowed rune U+002E

/cc @nigeltao

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone 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