Skip to content

Commit ea905f6

Browse files
committed
Z-1675 TarArchive.RootPath was case and slash direction sensitive and a trailing slash caused failure
1 parent 4742318 commit ea905f6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Tar/TarArchive.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
// exception statement from your version.
3535

3636
// HISTORY
37-
// 28-01-2010 DavidPierson Added IsStreamOwner
37+
// 2010-01-28 Added IsStreamOwner
38+
// 2012-06-07 Z-1675 RootPath was case and slash direction sensitive; trailing slash caused failure
3839

3940
using System;
4041
using System.IO;
@@ -315,8 +316,8 @@ public string RootPath
315316
if ( isDisposed ) {
316317
throw new ObjectDisposedException("TarArchive");
317318
}
318-
319-
rootPath = value;
319+
// Convert to forward slashes for matching. Trim trailing / for correct final path
320+
rootPath = value.Replace('\\', '/').TrimEnd('/');
320321
}
321322
}
322323

@@ -727,7 +728,7 @@ void WriteEntryCore(TarEntry sourceEntry, bool recurse)
727728
string newName = null;
728729

729730
if (rootPath != null) {
730-
if (entry.Name.StartsWith(rootPath)) {
731+
if (entry.Name.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase)) {
731732
newName = entry.Name.Substring(rootPath.Length + 1 );
732733
}
733734
}

0 commit comments

Comments
 (0)