From 6602bcddb19ab95e368425e713a1a7eecd271021 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 Sep 2024 00:06:23 -0700 Subject: [PATCH] Add zipinsecuretpath to rwp --- cmd/rwp/main.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/rwp/main.go b/cmd/rwp/main.go index 7e81713f..1c05f845 100644 --- a/cmd/rwp/main.go +++ b/cmd/rwp/main.go @@ -1,7 +1,22 @@ package main -import "github.com/readium/go-toolkit/cmd/rwp/cmd" +import ( + "os" + + "github.com/readium/go-toolkit/cmd/rwp/cmd" +) func main() { + // From the archive/zip docs: + // If any file inside the archive uses a non-local name + // (as defined by [filepath.IsLocal]) or a name containing backslashes + // and the GODEBUG environment variable contains `zipinsecurepath=0`, + // NewReader returns the reader with an [ErrInsecurePath] error. + if os.Getenv("GODEBUG") == "" { + os.Setenv("GODEBUG", "zipinsecurepath=0") + } else { + os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",zipinsecurepath=0") + } + cmd.Execute() }