Skip to content

Commit

Permalink
Updated VsixPackage to normalize names when finding zip entries to su…
Browse files Browse the repository at this point in the history
…pport backslash.
  • Loading branch information
garrettpauls committed Dec 15, 2015
1 parent 51c0d97 commit d223692
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion VSGallery.AtomGenerator/Vsix/VsixPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.RegularExpressions;

namespace VSGallery.AtomGenerator.Vsix
{
Expand Down Expand Up @@ -38,16 +39,25 @@ public Uri TrySavePreviewImage(string destinationFolder)
return _SaveEntry(destinationFolder, PreviewImageName);
}

private static string _NormalizeZipEntryName(string value)
{
value = value.Replace('\\', '/');
value = Regex.Replace(value, "[/]{2,}", "/");
return value;
}

private Uri _SaveEntry(string destinationFolder, string entryName)
{
if (string.IsNullOrEmpty(entryName))
{
return null;
}

entryName = _NormalizeZipEntryName(entryName);

using (var zip = ZipFile.OpenRead(File))
{
var entry = zip.Entries.FirstOrDefault(x => x.FullName == entryName);
var entry = zip.GetEntry(entryName);
if (entry == null)
{
return null;
Expand Down

0 comments on commit d223692

Please sign in to comment.