-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: fs.WalkDir fails if archive contains a directory without a trailing slash #50390
Comments
In the Selenium jar you link to, the directory |
Thanks for the analysis, Ian! With this and other issues we've hit when using archive/zip with io/fs.WalkDir (#50179), I'd be happy to dig in, but wanted to make sure this is something that archive/zip wants to support. If these JARs are just invalid ZIPs, that works for me. Based on your comment, it sounds like this may be valid, if peculiar. |
I don't know whether it is valid or not, but since it seems to happen it seems that we should handle it. I've written a CL that ignores duplicate entries. But I'm not sure whether that is correct. Perhaps we should give an error instead. |
Change https://golang.org/cl/374934 mentions this issue: |
Change https://golang.org/cl/374954 mentions this issue: |
Upon further thought I think the only safe approach is to reject an attempt to use the io/fs interfaces with an archive that has duplicate entries. That means that the Selenium jar will fail. Reporting an error seems clearly better to quietly hiding entries. |
Works for me! In hindsight, it's not obvious that we gain a lot by using fs.FS since we only support ZIP archives. Maybe a premature abstraction on our part? I think I may try iterating over zip.Reader.File instead of using fs.WalkDir. |
Please note that the filenames can be a dominating factor in some workloads involving lots of files (e.g. a compressed version of a node_modules directory). Would it be ok to reject one or the other syntax of filenames in JARs instead of running duplicate file detection? |
If someone chooses to use the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
We had a report of a JAR file where fs.WalkDir hit an error while walking the archive google/log4jscanner#12
JAR can be found here: https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-api/3.141.59
Reproducer (https://go.dev/play/p/-yKYcEqgotT):
What did you expect to see?
No error
What did you see instead?
The text was updated successfully, but these errors were encountered: