diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs index 1b5e01a68..b0c8b72cb 100644 --- a/src/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs +++ b/src/ICSharpCode.SharpZipLib/Zip/ZipNameTransform.cs @@ -95,17 +95,8 @@ public string TransformFile(string name) name = name.Replace(@"\", "/"); name = WindowsPathUtils.DropPathRoot(name); - // Drop any leading slashes. - while ((name.Length > 0) && (name[0] == '/')) - { - name = name.Remove(0, 1); - } - - // Drop any trailing slashes. - while ((name.Length > 0) && (name[name.Length - 1] == '/')) - { - name = name.Remove(name.Length - 1, 1); - } + // Drop any leading and trailing slashes. + name = name.Trim('/'); // Convert consecutive // characters to / int index = name.IndexOf("//", StringComparison.Ordinal);