Skip to content

archive/zip: NonUTF8 does not work #72751

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

Closed
mattn opened this issue Mar 9, 2025 · 7 comments
Closed

archive/zip: NonUTF8 does not work #72751

mattn opened this issue Mar 9, 2025 · 7 comments
Labels
BugReport Issues describing a possible bug in the Go implementation.

Comments

@mattn
Copy link
Member

mattn commented Mar 9, 2025

Go version

go version devel go1.24-608acff847 Wed Jan 22 10:13:04 2025 -0800 windows/amd64

Output of go env in your module/workspace:

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=1
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\mattn\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\mattn\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\mattn\AppData\Local\Temp\go-build942228727=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=C:\dev\go-tip\src\go.mod
set GOMODCACHE=C:\Users\mattn\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\mattn\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\dev\go-tip
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\mattn\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=c:\dev\go-tip\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.24-608acff847 Wed Jan 22 10:13:04 2025 -0800
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

Run this Go code.

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

What did you see happen?

filename was broken.

Image

What did you expect to see?

Image

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 9, 2025
@seankhliao
Copy link
Member

As far as I can tell, you put a utf8 string in the name field, but marked it as not utf8. It's expected to be broken in whatever encoding unzip decided to try to decode the name with.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2025
@mattn
Copy link
Member Author

mattn commented Mar 9, 2025

No, this worked correctly previously. At least this commit. 0a3f3e1

@mattn
Copy link
Member Author

mattn commented Mar 9, 2025

BTW, NonUTF8 will not work correctly whether it is set to true or false.

@seankhliao
Copy link
Member

I think that's #44187

it works with:

	h := &zip.FileHeader{
		Name: filename,
		Method:   zip.Deflate,
		Modified: time.Now(),
	}

@mattn
Copy link
Member Author

mattn commented Mar 9, 2025

Yes, this is #44187

@mattn
Copy link
Member Author

mattn commented Mar 9, 2025

And I noticed ZipWriter.Create always not set Modified field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation.
Projects
None yet
Development

No branches or pull requests

3 participants