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

archive/zip: fails to encode filenames with utf-8 chars if 'Modified' is not set #44187

Open
Bysmyyr opened this issue Feb 9, 2021 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Bysmyyr
Copy link

Bysmyyr commented Feb 9, 2021

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

➜ go version
go version go1.15.6 linux/amd64


Does this issue reproduce with the latest release?

that's almost latests

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

go env Output
➜ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/olli/.cache/go-build"
GOENV="/home/olli/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/olli/go/pkg/mod"
GONOPROXY="github.com/SharperShape"
GOOS="linux"
GOPATH="/home/olli/go"
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/olli/code/ziponator/go.mod"
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-build503259521=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Creating a zipfile with nonASCII characters in zipped files fail to encode if Modified is not set. The behavior could be ok still but currently, it anyway checks that if utf-8 mode is needed which makes the programmer to think it should work without any tricks.

so:

w := zip.NewWriter(os.Stdout)
f, err := w.Create("asdää123ääääääend")
… write to f …

…doesn't work, but:

w := zip.NewWriter(os.Stdout)
fh := zip.FileHeader{
	Name:   "asdää123ääääääend",
	Method: zip.Deflate,
	Modified: time.Now(),
}
f, err := w.CreateHeader(&fh)

works

Problem confirmed here:
https://gophers.slack.com/archives/C029RQSEE/p1612881140479100?thread_ts=1612878897.474000&cid=C029RQSEE

What did you expect to see?

asdää123ääääääend

What did you see instead?

asd├д├д123├д├д├д├д├д├дend

@Bysmyyr Bysmyyr changed the title Zip fails utf encode filenames with utf-8 chars if 'Modified' is not set Zip fails utf-8 encode filenames with utf-8 chars if 'Modified' is not set Feb 9, 2021
@Bysmyyr Bysmyyr changed the title Zip fails utf-8 encode filenames with utf-8 chars if 'Modified' is not set Zip fails encode filenames with utf-8 chars if 'Modified' is not set Feb 9, 2021
@dmitshur dmitshur changed the title Zip fails encode filenames with utf-8 chars if 'Modified' is not set archive/zip: fails to encode filenames with utf-8 chars if 'Modified' is not set Feb 9, 2021
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 9, 2021
@dmitshur dmitshur added this to the Backlog milestone Feb 9, 2021
@dmitshur
Copy link
Contributor

dmitshur commented Feb 9, 2021

CC @dsnet, @bradfitz via owners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants