Skip to content

Commit 5285f17

Browse files
authored
Add zipinsecurepath to rwp (#103)
1 parent 497974a commit 5285f17

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cmd/rwp/main.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
package main
22

3-
import "github.com/readium/go-toolkit/cmd/rwp/cmd"
3+
import (
4+
"os"
5+
6+
"github.com/readium/go-toolkit/cmd/rwp/cmd"
7+
)
48

59
func main() {
10+
// From the archive/zip docs:
11+
// If any file inside the archive uses a non-local name
12+
// (as defined by [filepath.IsLocal]) or a name containing backslashes
13+
// and the GODEBUG environment variable contains `zipinsecurepath=0`,
14+
// NewReader returns the reader with an [ErrInsecurePath] error.
15+
if os.Getenv("GODEBUG") == "" {
16+
os.Setenv("GODEBUG", "zipinsecurepath=0")
17+
} else {
18+
os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",zipinsecurepath=0")
19+
}
20+
621
cmd.Execute()
722
}

0 commit comments

Comments
 (0)