Use forward slashes in ZIP files; rewrite archive tests; refine error msg#1534
Conversation
|
Is this actually a problem in the |
In progress. |
This is actually a problem in the
I agree. However, waiting for the fix from upstream will be slow, while using my dirty fix will solve it right away.
Unfortunately, the There are some issues about path handling in that crate:
There is also a comment about using 3rd-party library to handle paths instead of Footnotes |
|
Hey, I'd love to get this merged. Sorry for not giving this any attention these last few weeks. Could you please add a test for Windows so we know it won't be broken again in the future? |
|
No problem. Let me add necessary tests. |
|
Ah-oh, workflows have not been approved. Let's wait for the Windows CI to fail, then I'll commit to revert the latest commit and you can merge it. |
|
Please, the last two steps. |
|
It looks like this currently only contains the tests but not the fixes. |
Yep. That was the second to last step - let the test fail on Windows only. I made it. Now we have the fix: 3b59a69 . |
- sort imports - clean dependency - refine comments and English - use long parameter Co-authored-by: Sven-Hendrik Haase <[email protected]>
Timing issue? It runs fine before. |
Hm yeah, probably a timing issue. :/ You're very welcome to take a look at that if you want. |
|
Hey, I'd love to get this into the next release of miniserve. Do you think you'll have some time to finish this up soon? Looks like there's only some testing stuff remaining. I can also help you finish this up if you like. |
- Universal definitions. - Reuse HTTP client. - Docstring.
|
@svenstaro: sorry for being late. Please see a076fd3 . This is a rewrite. |
Bruh, it works on my machine ™. |
|
Hi, @svenstaro ! Does the current revision look good? |
src/archive.rs
Outdated
|
|
||
| // Workaround for Windows path in ZIP files: | ||
| // Always use forward slashes for all paths to avoid literal backslashes in saved entry path. | ||
| // TODO: remove this when the "zip" cargo has the ability to process a directory as a whole. |
There was a problem hiding this comment.
According to zip-rs/zip2#376 and the release notes of zip v7.2.0, this is now handled by upstream. At least I see they now have tests handling this. Could you check out whether that now does the job? It's a bit odd though that they have that issue still open.
There was a problem hiding this comment.
a06e31e. It seems to work. I'll test it soon.
There was a problem hiding this comment.
a06e31e. It seems to work. I'll test it soon.
It still does not work on macOS (#1534 (comment)). Reverted by 9f8b0de and a new comment has been added.
svenstaro
left a comment
There was a problem hiding this comment.
Tiny nit but apart from that I really like these tests. I was at first a bit skeptical about the ArchiveKind thing as it adds some complexity but I think here it actually makes sense in the context of the archives_links_and_downloads test.
|
Happy to merge after you figure out whether upstream's fix works for us. :) |
|
This is the last PR before releasing v0.33.0 :) |
The 2nd parameter of "assert!()" has "format!()" integrated. Co-authored-by: Sven-Hendrik Haase <[email protected]>
Our dependency "zip" has fixed a bug about setting local platform in the ZIP since v7.2.0: zip-rs/zip2@9e9badd, so we don't need to fix it here. This effectively reverts the main part of commits: - The fix: ad8d3d9 (the origin) or 3b59a69 (the re-applied one) - The test: 90c5234
|
Is this still draft or shall I review it? |
|
Sorry for the delay. I didn't have a macOS with me several hours ago. Unfortunately, on macOS, Finder does not treat those backslashes as path separators even though we have already correctly set the field after switching to the newest "zip" package:
$ zipinfo -v .../wwwroot.zip | grep 'file system'
file system or operating system of origin: MS-DOS, OS/2 or NT FAT
minimum file system compatibility required: MS-DOS, OS/2 or NT FAT
...
BEFORE:
$ zipinfo -v .../wwwroot.zip | grep 'file system'
file system or operating system of origin: Unix
minimum file system compatibility required: MS-DOS, OS/2 or NT FAT
...
However, both PeaZip and 7-Zip agree with us:
Path parsing in ZIP looks implementation dependent. Since we have this:
I think using forward slashes is necessary and more safe. Let me re-revert the code. Sorry for the noise. Btw, the "zip" package works as expected: it names the saved item exactly what the user specified. |
|
Some really peculiar behavior from zip here. Thanks for looking into this! |
macOS: rememeber, no forward slashes. This reverts commit a06e31e.
| fn fetch_index_document( | ||
| reqwest_client: &Client, | ||
| server: &TestServer, | ||
| expected: StatusCode, | ||
| ) -> Result<Document, Error> { | ||
| let resp = reqwest_client.get(server.url()).send()?; | ||
| assert_eq!(resp.status(), expected); | ||
|
|
||
| Ok(Document::from_read(resp)?) | ||
| } |
There was a problem hiding this comment.
I think it would probably make sense to make this a universal utility and then use it everywhere? We have sooo many Document::from_reads in all the tests that this might be a great follow-up to tidy up some test code if you're up for it. At any rate, this should probably go into tests/utils/mod.rs for now.
There was a problem hiding this comment.
Actually, let's do that in a follow-up. I wanna get this one merged at long last.
There was a problem hiding this comment.
oops, I'm coding for this. Thank you for reviewing my PR. I think this cleanup will be made in following PRs after the upcoming new verison.
oops Co-authored-by: Sven-Hendrik Haase <[email protected]>


Hello!
I'm running miniserve on Windows. I found that my files in produced ZIP files cannot be correctly extracted on macOS, but Windows Explorer didn't complain about it. After reading a post 1, I thought I can fix it. Now here's the PR.
I'm new to Rust. Please review my code and help me correct anything wrong.
My test. Run it on Git Bash (untested on WSL):
Bash shell script
The output before this PR:
The output for now:
Before applying this fix, third-party archive utilities, for example PeaZip and 7-Zip, can't understand those backslashes:
However, Windows Explorer always shows the correct directory hierarchy despite this fix:
.
Footnotes
windows - Zip files expand with backslashes on Linux, no subdirectories - Super User - https://superuser.com/q/1382839 ↩