@@ -244,11 +244,14 @@ public void WriteZipStreamWithNoCompression([Values(0, 1, 256)] int contentLengt
244
244
using ( var dummyZip = Utils . GetDummyFile ( 0 ) )
245
245
using ( var inputFile = Utils . GetDummyFile ( contentLength ) )
246
246
{
247
+ // Filename is manually cleaned here to prevent this test from failing while ZipEntry doesn't automatically clean it
248
+ var inputFileName = ZipEntry . CleanName ( inputFile . Filename ) ;
249
+
247
250
using ( var zipFileStream = File . OpenWrite ( dummyZip . Filename ) )
248
251
using ( var zipOutputStream = new ZipOutputStream ( zipFileStream ) )
249
252
using ( var inputFileStream = File . OpenRead ( inputFile . Filename ) )
250
253
{
251
- zipOutputStream . PutNextEntry ( new ZipEntry ( inputFile . Filename )
254
+ zipOutputStream . PutNextEntry ( new ZipEntry ( inputFileName )
252
255
{
253
256
CompressionMethod = CompressionMethod . Stored ,
254
257
} ) ;
@@ -260,7 +263,6 @@ public void WriteZipStreamWithNoCompression([Values(0, 1, 256)] int contentLengt
260
263
{
261
264
var inputBytes = File . ReadAllBytes ( inputFile . Filename ) ;
262
265
263
- var inputFileName = ZipEntry . CleanName ( inputFile . Filename ) ;
264
266
var entry = zf . GetEntry ( inputFileName ) ;
265
267
Assert . IsNotNull ( entry , "No entry matching source file \" {0}\" found in archive, found \" {1}\" " , inputFileName , zf [ 0 ] . Name ) ;
266
268
@@ -282,6 +284,35 @@ public void WriteZipStreamWithNoCompression([Values(0, 1, 256)] int contentLengt
282
284
}
283
285
}
284
286
287
+ [ Test ]
288
+ [ Category ( "Zip" ) ]
289
+ [ Category ( "KnownBugs" ) ]
290
+ public void ZipEntryFileNameAutoClean ( )
291
+ {
292
+ using ( var dummyZip = Utils . GetDummyFile ( 0 ) )
293
+ using ( var inputFile = Utils . GetDummyFile ( ) ) {
294
+ using ( var zipFileStream = File . OpenWrite ( dummyZip . Filename ) )
295
+ using ( var zipOutputStream = new ZipOutputStream ( zipFileStream ) )
296
+ using ( var inputFileStream = File . OpenRead ( inputFile . Filename ) )
297
+ {
298
+ zipOutputStream . PutNextEntry ( new ZipEntry ( inputFile . Filename )
299
+ {
300
+ CompressionMethod = CompressionMethod . Stored ,
301
+ } ) ;
302
+
303
+ inputFileStream . CopyTo ( zipOutputStream ) ;
304
+ }
305
+
306
+ using ( var zf = new ZipFile ( dummyZip . Filename ) )
307
+ {
308
+ Assert . AreNotEqual ( ZipEntry . CleanName ( inputFile . Filename ) , zf [ 0 ] . Name ,
309
+ "Entry file name \" {0}\" WAS automatically cleaned, this test should be removed" , inputFile . Filename ) ;
310
+ }
311
+
312
+ Assert . Warn ( "Entry file name \" {0}\" was not automatically cleaned" , inputFile . Filename ) ;
313
+ }
314
+ }
315
+
285
316
/// <summary>
286
317
/// Empty zips can be created and read?
287
318
/// </summary>
0 commit comments