Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json.Unmarmal bug for escape charactors #31537

Closed
robin11 opened this issue Apr 18, 2019 · 1 comment
Closed

json.Unmarmal bug for escape charactors #31537

robin11 opened this issue Apr 18, 2019 · 1 comment

Comments

@robin11
Copy link

robin11 commented Apr 18, 2019

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

$ go version
go version go1.11.2 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/haochuan.lj/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/robin/gowork"
GOPROXY=""
GORACE=""
GOROOT="/opt/go"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build943900655=/tmp/go-build -gno-record-gcc-switches"

What did you do?

type Conf struct {
	lineSeparator string `json:"line_separator"`
}

func main() {
	var s = `{"line_separator":"\0001\n"}`
	m := map[string]string{}
	err := json.Unmarshal([]byte(s), &m)
	fmt.Println(err)
}

What did you expect to see?

err is nil

What did you see instead?

invalid character '0' in string escape code

@robin11
Copy link
Author

robin11 commented Apr 18, 2019

related code
image

@robin11 robin11 closed this as completed Apr 18, 2019
@golang golang locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants