]> Cypherpunks repositories - gostls13.git/commitdiff
archive/zip: add docs on type of slashes in paths
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 17 Apr 2013 20:25:12 +0000 (13:25 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 17 Apr 2013 20:25:12 +0000 (13:25 -0700)
Fixes #5307

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8676046

src/pkg/archive/zip/struct.go
src/pkg/archive/zip/writer.go

index ea067f3554fafdcecdc023807b2675238b5157a8..73972d41cf0c9d8d95628bbd3322a8f51dba9144 100644 (file)
@@ -64,8 +64,15 @@ const (
        zip64ExtraId = 0x0001 // zip64 Extended Information Extra Field
 )
 
+// FileHeader describes a file within a zip file.
+// See the zip spec for details.
 type FileHeader struct {
-       Name               string
+       // Name is the name of the file.
+       // It must be a relative path: it must not start with a drive
+       // letter (e.g. C:) or leading slash, and only forward slashes
+       // are allowed.
+       Name string
+
        CreatorVersion     uint16
        ReaderVersion      uint16
        Flags              uint16
index 4c696e1529e8d08cfe45c10a93c20c9903e19fba..e9f147cea666f6de177f07f3bb61b16cb7380f5c 100644 (file)
@@ -163,6 +163,9 @@ func (w *Writer) Close() error {
 
 // Create adds a file to the zip file using the provided name.
 // It returns a Writer to which the file contents should be written.
+// The name must be a relative path: it must not start with a drive
+// letter (e.g. C:) or leading slash, and only forward slashes are
+// allowed.
 // The file's contents must be written to the io.Writer before the next
 // call to Create, CreateHeader, or Close.
 func (w *Writer) Create(name string) (io.Writer, error) {