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 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 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 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

@gopherbot gopherbot commented Aug 26, 2017

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

@gopherbot gopherbot closed this in fda8269 Aug 31, 2017
@mattn
Copy link
Member

@mattn 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.