Commit 8acaacb6 authored by Matthew Dempsky's avatar Matthew Dempsky

compress/gzip: clarify Latin-1 restrictions on gzip.Header

Fixes #12361.

Change-Id: Ifd62e8d93b2d733e67e0186c7185cd6291d3bbc1
Reviewed-on: https://go-review.googlesource.com/13939Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 63862afb
...@@ -43,6 +43,9 @@ var ( ...@@ -43,6 +43,9 @@ var (
// The gzip file stores a header giving metadata about the compressed file. // The gzip file stores a header giving metadata about the compressed file.
// That header is exposed as the fields of the Writer and Reader structs. // That header is exposed as the fields of the Writer and Reader structs.
//
// Strings must be UTF-8 encoded and may only contain Unicode code points
// U+0001 through U+00FF, due to limitations of the GZIP file format.
type Header struct { type Header struct {
Comment string // comment Comment string // comment
Extra []byte // "extra data" Extra []byte // "extra data"
......
...@@ -44,10 +44,7 @@ type Writer struct { ...@@ -44,10 +44,7 @@ type Writer struct {
// Writes may be buffered and not flushed until Close. // Writes may be buffered and not flushed until Close.
// //
// Callers that wish to set the fields in Writer.Header must do so before // Callers that wish to set the fields in Writer.Header must do so before
// the first call to Write or Close. The Comment and Name header fields are // the first call to Write, Flush, or Close.
// UTF-8 strings in Go, but the underlying format requires NUL-terminated ISO
// 8859-1 (Latin-1). NUL or non-Latin-1 runes in those strings will lead to an
// error on Write.
func NewWriter(w io.Writer) *Writer { func NewWriter(w io.Writer) *Writer {
z, _ := NewWriterLevel(w, DefaultCompression) z, _ := NewWriterLevel(w, DefaultCompression)
return z return z
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment