Navigation Menu

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: support "end of central directory record comment" (not file header comment) #21634

Closed
yanolab opened this issue Aug 26, 2017 · 4 comments
Milestone

Comments

@yanolab
Copy link
Contributor

yanolab commented Aug 26, 2017

ZIP formart has 2 types comment.
First, Central directory file header comment. This is already supported.
Second, End of central directory record comment. Read this comment is supported, but Write is not supported yet.

(more detail of zip format, see also: https://en.wikipedia.org/wiki/Zip_(file_format))

Not supported go source code is bellow.
https://github.com/golang/go/blob/master/src/archive/zip/writer.go#L185

I think following commit is mistake, because file header comment had been supported since Go1 released.
bcc349a

I propose to support "end of central directory record comment".

Proposal:

Add SetComment method to zip.Writer, such as bellow.

def (w *Writer) SetComment(c string) error

I will send patch if this proposal is acceptable.

@dsnet
Copy link
Member

dsnet commented Aug 26, 2017

For symmetry with Reader, it is probably better to add a Writer.Comment field with the documentation that it must be set before Writer.Close is called.

But the feature request sounds good to me.

@dsnet dsnet added this to the Go1.10 milestone Aug 26, 2017
@yanolab
Copy link
Contributor Author

yanolab commented Aug 26, 2017

@dsnet
Thank you for your reply.
Certainly, you're right that for symmetry.
I'll add a field with the document.
However, I think Reader.Comment should not be settable.
I wonder why Reader.Comment is a settable field.

@gopherbot
Copy link

Change https://golang.org/cl/59310 mentions this issue: archive/zip: support "end of central directory record comment"

@mattn
Copy link
Member

mattn commented Sep 26, 2017

If the magic number 'PK..' is in the comment as likely as 'end of central directory record comment', I wonder extract is intended.

@golang golang locked and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants