Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Core/Net/NetFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public class NetFileCache : IDisposable
private static readonly Regex cacheFileRegex = new Regex("^[0-9A-F]{8}-", RegexOptions.Compiled);
private static readonly ILog log = LogManager.GetLogger(typeof (NetFileCache));

static NetFileCache()
{
// SharpZibLib 1.1.0 changed this to default to false, but we depend on it for international mods.
// https://github.com/icsharpcode/SharpZipLib/issues/591
ZipStrings.UseUnicode = true;
}

/// <summary>
/// Initialize a cache given a GameInstanceManager
/// </summary>
Expand Down
13 changes: 12 additions & 1 deletion Tests/Core/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void RemoveCache()
cache.Dispose();
cache = null;
module_cache.Dispose();
module_cache = null;
module_cache = null;
Directory.Delete(cache_dir, true);
}

Expand Down Expand Up @@ -206,6 +206,17 @@ public void ZipValid_ContainsFilenameWithBadChars_NoException()
Thread.CurrentThread.CurrentUICulture = origUICulture;
}

[Test]
public void ZipValid_ContainsFilenameWithUnicodeChars_Valid()
{
bool valid = false;
string reason = null;

Assert.DoesNotThrow(() =>
valid = NetFileCache.ZipValid(TestData.ZipWithUnicodeChars, out reason));
Assert.IsTrue(valid, reason);
}

[Test]
public void EnforceSizeLimit_UnderLimit_FileRetained()
{
Expand Down
5 changes: 5 additions & 0 deletions Tests/Data/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public static string DogeCoinFlag_101_LZMA()
/// </summary>
public static readonly string ZipWithBadChars = DataDir("ZipWithBadChars.zip");

/// <summary>
/// Contains files with names that differ in their Unicode and "original" representation.
/// </summary>
public static readonly string ZipWithUnicodeChars = DataDir("ZipWithUnicodeChars.zip");

///<summary>
/// DogeCoinFlag 1.01 info. This contains a bug where the
/// install stanza doesn't actually refer to any files.
Expand Down
Binary file added Tests/Data/ZipWithUnicodeChars.zip
Binary file not shown.
1 change: 1 addition & 0 deletions Tests/GUI/GH1866.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Tests.GUI
/// which involves sorting the GUI table by Max KSP Version and then performing a repo operation.
/// </summary>
[TestFixture]
[NUnit.Framework.Category("Display")]
public class GH1866
{
private CkanModule _anyVersionModule;
Expand Down