Skip to content

Commit af0ee8d

Browse files
committed
Z-1676 Translate to forward slashes and remove drive from name in ZipEntry constructor, mainly for ZipOutputStream entry path names
1 parent 89c5dec commit af0ee8d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Zip/ZipEntry.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
// 2009-12-22 Z-1649 Added AES support
4242
// 2010-02-02 DavidP Changed NTFS Extra Data min length to 4
4343
// 2012-06-03 Z-1744 Use only the low order byte of "Version Needed to Extract"
44+
// 2012-07-18 Z-1676 Translate to forward slashes and remove drive from name in constructor
4445

4546
using System;
4647
using System.IO;
@@ -220,7 +221,7 @@ internal ZipEntry(string name, int versionRequiredToExtract, int madeByInfo,
220221
CompressionMethod method)
221222
{
222223
if (name == null) {
223-
throw new System.ArgumentNullException("name");
224+
throw new ArgumentNullException("name");
224225
}
225226

226227
if ( name.Length > 0xffff ) {
@@ -231,8 +232,8 @@ internal ZipEntry(string name, int versionRequiredToExtract, int madeByInfo,
231232
throw new ArgumentOutOfRangeException("versionRequiredToExtract");
232233
}
233234

234-
this.DateTime = System.DateTime.Now;
235-
this.name = name;
235+
this.DateTime = DateTime.Now;
236+
this.name = CleanName(name);
236237
this.versionMadeBy = (ushort)madeByInfo;
237238
this.versionToExtract = (ushort)versionRequiredToExtract;
238239
this.method = method;
@@ -1205,7 +1206,7 @@ public static string CleanName(string name)
12051206
return string.Empty;
12061207
}
12071208

1208-
if (Path.IsPathRooted(name) == true) {
1209+
if (Path.IsPathRooted(name)) {
12091210
// NOTE:
12101211
// for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt
12111212
name = name.Substring(Path.GetPathRoot(name).Length);

0 commit comments

Comments
 (0)