Skip to content

Commit ecea9a3

Browse files
authored
Re-enable Windows_ZipWithInvalidFileNames tests (#55434)
Since we have shipped for 3 years with the current behavior, re-enabling the test so it ensures the current behavior going forward. Extracting .zip files with invalid file names throw an IOException with a message "The filename, directory name, or volume label syntax is incorrect.". Contributes to #25099
1 parent f22685f commit ecea9a3

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/libraries/System.IO.Compression.ZipFile/tests/ZipFile.Extract.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,25 @@ public void Unix_ZipWithOSSpecificFileNames(string zipName, string fileName)
9494
/// when an attempt is made to extract them.
9595
/// </summary>
9696
[Theory]
97-
[ActiveIssue("https://github.com/dotnet/runtime/issues/25099")]
98-
[InlineData("WindowsInvalid_FromUnix", null)]
99-
[InlineData("WindowsInvalid_FromWindows", null)]
100-
[InlineData("NullCharFileName_FromWindows", "path")]
101-
[InlineData("NullCharFileName_FromUnix", "path")]
97+
[InlineData("NullCharFileName_FromWindows")]
98+
[InlineData("NullCharFileName_FromUnix")]
99+
[PlatformSpecific(TestPlatforms.Windows)] // Checks Windows-specific invalid file path
100+
public void Windows_ZipWithInvalidFileNames_ThrowsArgumentException(string zipName)
101+
{
102+
AssertExtensions.Throws<ArgumentException>("path", null, () => ZipFile.ExtractToDirectory(compat(zipName) + ".zip", GetTestFilePath()));
103+
}
104+
105+
/// <summary>
106+
/// This test ensures that a zipfile with path names that are invalid to this OS will throw errors
107+
/// when an attempt is made to extract them.
108+
/// </summary>
109+
[Theory]
110+
[InlineData("WindowsInvalid_FromUnix")]
111+
[InlineData("WindowsInvalid_FromWindows")]
102112
[PlatformSpecific(TestPlatforms.Windows)] // Checks Windows-specific invalid file path
103-
public void Windows_ZipWithInvalidFileNames_ThrowsArgumentException(string zipName, string paramName)
113+
public void Windows_ZipWithInvalidFileNames_ThrowsIOException(string zipName)
104114
{
105-
AssertExtensions.Throws<ArgumentException>(paramName, null, () => ZipFile.ExtractToDirectory(compat(zipName) + ".zip", GetTestFilePath()));
115+
AssertExtensions.Throws<IOException>(() => ZipFile.ExtractToDirectory(compat(zipName) + ".zip", GetTestFilePath()));
106116
}
107117

108118
[Theory]

0 commit comments

Comments
 (0)