-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Tell SharpZipLib to use Unicode when opening zips #3345
Conversation
This comment has been minimized.
This comment has been minimized.
Oh, good idea! They are also only called once, which is not required but nice to have here. |
8c7a513
to
d756f99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try it! 🛸
We can probably use xvfb if we need to run headless tests that require a framebuffer. ➜ ~ Xvfb :99 &; export DISPLAY=:99; echo $DISPLAY
[1] 24107
:99 |
We already do so in CI: CKAN/.github/workflows/build.yml Line 54 in 9c265dc
But I don't want to install and set up xvfb a hundred times in a short-lived container for testing something completely unrelated. |
It actually worked! 🤩 |
Heck yeah! Good work @DasSkelett |
Problem
Follow-up to #3329 – we still don't know whether it fixed #3342, but it probably didn't.
SharpZipLib did indeed change stuff regarding zip files with Unicode chars in the path strings, however not the way we wanted (icsharpcode/SharpZipLib#591), instead they are now defaulting to not use Unicode. This makes some mod inflations fail:
A short zip + Unicode introduction according to how I understand it:
From zip(1):
If a file path string in a zip contains Unicode chars, some zip programs seem to save two versions of this path string: one "standard local path for backward compatibility", and the UTF-8 translation of it.
Now depending on the tool and configuration used to read these zips again, they either try to use the "standard" path or the UTF-8 path, where the standard path seems to be failing on some systems, probably depending on whether you have the matching locales/code pages installed or not. The Unicode path should always work fine.
Solution
Now we force SharpZipLib to use the Unicode path. This is currently only possible with a global static bool, but things are likely to change again soon (icsharpcode/SharpZipLib#592).
The bool is set to
true
in theNetFileCache
constructor, which I think is the most straight-forward and reliable place for it, since it is guaranteed to be called whenever and before we use the cache, which is when we are about to try to read zips.I've also managed to write a unit test for it, thanks to @techman83 providing a small test zip that reproduces the behaviour we see from all the other international zips.
The test isn't worth much at least on my system because the zips somehow are read successfully even without
ZipStrings.UseUnicode = true;
, but in a freshmono
container the test would fail withoutZipStrings.UseUnicode = true;
.I've also marked the
GH1866
tests with a new categoryDisplay
to have an easy way to ignore them, since they require either a real or a mock up display (which I didn't want to bother with in the Docker container).Hopefully fixes #3342
Likely fixes all the inflation errors with
Name is invalid
, at least inflating them in a mono container works with the fix (and fails without it)