-
Notifications
You must be signed in to change notification settings - Fork 4.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
Added test for extracting zip files with invalid characters in Windows #67332
Conversation
Tagging subscribers to this area: @dotnet/area-system-io-compression Issue DetailsRelates to #67201
|
Thanks. We will need the fix as well before we can merge this 😸 |
src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Extract.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Extract.cs
Outdated
Show resolved
Hide resolved
@danmoseley I removed all of the |
{ | ||
var testDirectory = GetTestFilePath(); | ||
ZipFile.ExtractToDirectory(compat("InvalidWindowsFileNameChars.zip"), testDirectory); | ||
Assert.True(File.Exists(testDirectory + "Test______________________________________.txt")); |
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.
Please use Path.Combine
not +
- see other tests.
Test looks good with comments above. Please also push up the fix now, that makes this test pass locally for you. |
BTW, it's fine doing things this way for your first PR 😄 but generally we would push up a PR when it's all done -- meaning tests+fix. We verify that the tests fail without the fix, but we do it locally beforehand. |
src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Extract.cs
Outdated
Show resolved
Hide resolved
@danmoseley Oh, I thought when you said to write the tests first and verify it fails, I thought I was supposed to verify it fails on the GitHub repo rather than my local computer. That was the reason I asked if I should do it one go or separately. I was going to start writing the fix but I cannot build the repo now due to some technical issue apparently. Once that is fixed and I can build the repo I will start the fix and probably push it by tomorrow. BTW, thank you for helping, I am quite unfamiliar with all of this. I must have been a headache with all the questions :) |
Yes, I was unclear 😄 What is the technical issue? Your link is to the install script. |
@danmoseley It doesn't build
The link says the following
Update: Install script is back |
@danmoseley I would be more than happy to continue contributing after this one. |
@ViktorHofer thanks. Why would we introduce a PNSE TFM when browser+windows+unix covers everything? Simplest thing then seems to leave the Windows build as the platform agnostic one. I think that means
|
@danmoseley Asking just out of curiosity, why do we assume windows to be the default when the windows filename rules are the exception? Wouldn't sanitizing only the null character be better when targeting a new platform perhaps? |
As far as I'm aware, the only target that doesn't match browser and Unix is Windows, so it doesn't matter. If we add a new target, we would need to change other things too. I am not sure what the implications are of changing the default one, although @ViktorHofer would know. |
@danmoseley I don't know if it would change anything code-wise but I was thinking as a design. |
The question is, how would you default if you would handle this during runtime? Option A
In our world where we don't use runtime conditions but build for specific platforms we would implement Option A the following way: <PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)</NetCoreAppCurrent>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.PNSEMEssage</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup> Option B
That would be implemented this way: <PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-Unix</NetCoreAppCurrent>
</PropertyGroup> Choosing Option A requires an additional inner build (for the PNSE configuration) which is a significant cost compared to runtime checks. We should aim at not over-building as every additional project evaluation, msbuild target execution and compiler invocation adds to the overall build. That said, if a PNSE makes most sense for the library, it makes sense to choose it.
You can always move around the default as long as you make sure that the right platform gets the right implementation (via conditions on the item groups).
It might cover everything today but whenever we add a new platform we want our libraries to have a good default setting. In the past we chose Unix as the default as the most platforms builds on top of it. Choosing Windows as a default doesn't make much sense IMO as there is only a single platform (Windows) that would work with the implementation (assuming that the current Windows implementation is actually platform specific and not agnostic). |
Ok it sounds like we should default to the Unix behavior as you suggested @Danyy427 . Do you want to make that change? |
@danmoseley I tried, hopefully I understood @ViktorHofer's answer correctly. |
src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression.ZipFile/src/System.IO.Compression.ZipFile.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Create.cs
Outdated
Show resolved
Hide resolved
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.
From an infrastructure perspective this looks great. Thanks
…te.cs Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
@danmoseley Are we supposed to do anything else to get this thing to merge? |
@Danyy427 nope, just letting tests run. @dotnet/dnceng something happened here with Azdo https://dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_apis/build/builds/1711221/logs/662 |
Thanks for reporting the problem @danmoseley. I haven't seen this error before but I'll create an issue to monitor this error. I see that you already retried the build, hopefully it succeeds this time |
Thanks @Danyy427. You ran into one or two more problems (on our side) than most PR's encounter! |
@danmoseley It’s okay I guess. Thanks for all the help you have given, it has been most useful. I will most certainly comtinue contributing. And this will certainly not be the last time I will give you a headache from all the questions. :) |
Always happy to help. As I mentioned earlier, from experience I highly recommend new folks get a number of easy, short PR's merged before tackling anything larger. Partly just because it takes time to get used to a repo's style, etc. |
@danmoseley Yeah, probably that’s foe the best. I browsed a couple of those easy and up-for-grabs. There are some which are like a year old and almost forgotten. I may continue with those perhaps as early as tomorrow |
Relates to #67201