Update SharpZipLib to 1.1.0.

The default code page has been changed to UTF8
so our workarounds are no longer needed.
This commit is contained in:
Paul Chote
2019-03-30 15:46:05 +00:00
committed by Oliver Brakmann
parent 9cbf08201f
commit f69c6ab3fb
7 changed files with 9 additions and 55 deletions

View File

@@ -15,7 +15,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Checksum;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams; using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using OpenRA.Primitives; using OpenRA.Primitives;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.FileSystem
public ReadOnlyZipFile(Stream s, string filename) public ReadOnlyZipFile(Stream s, string filename)
{ {
Name = filename; Name = filename;
pkg = ZipFileHelper.Create(s); pkg = new ZipFile(s);
} }
public Stream GetStream(string filename) public Stream GetStream(string filename)
@@ -113,7 +113,7 @@ namespace OpenRA.FileSystem
} }
pkgStream.Position = 0; pkgStream.Position = 0;
pkg = ZipFileHelper.Create(pkgStream); pkg = new ZipFile(pkgStream);
Name = filename; Name = filename;
} }

View File

@@ -160,7 +160,6 @@
<Compile Include="Primitives\Size.cs" /> <Compile Include="Primitives\Size.cs" />
<Compile Include="Primitives\SpatiallyPartitioned.cs" /> <Compile Include="Primitives\SpatiallyPartitioned.cs" />
<Compile Include="Primitives\ConcurrentCache.cs" /> <Compile Include="Primitives\ConcurrentCache.cs" />
<Compile Include="Primitives\ZipFileHelper.cs" />
<Compile Include="SelectableExts.cs" /> <Compile Include="SelectableExts.cs" />
<Compile Include="Selection.cs" /> <Compile Include="Selection.cs" />
<Compile Include="Server\Connection.cs" /> <Compile Include="Server\Connection.cs" />

View File

@@ -1,46 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.IO;
using System.Text;
using ICSharpCode.SharpZipLib.Zip;
namespace OpenRA.Primitives
{
public static class ZipFileHelper
{
/// <summary>
/// Creates a <see cref="ZipFile"/> with UTF8 encoding. Avoid using <see cref="ZipFile(Stream)"/> as you
/// cannot be sure of the encoding that will be used.
/// </summary>
public static ZipFile Create(Stream stream)
{
// SharpZipLib uses this global as the encoding to use for all ZipFiles.
// The initial value is the system code page, which causes several problems.
// 1) On some systems, the code page for a certain encoding might not even be installed.
// 2) The code page is different on every system, resulting in unpredictability.
// 3) The code page might not work for decoding some archives.
// We set the default to UTF8 instead which fixes all these problems.
ZipConstants.DefaultCodePage = Encoding.UTF8.CodePage;
return new ZipFile(stream);
}
/// <summary>
/// Creates a <see cref="ZipFile"/> with UTF8 encoding. Avoid using <see cref="ZipFile(FileStream)"/> as you
/// cannot be sure of the encoding that will be used.
/// </summary>
public static ZipFile Create(FileStream stream)
{
ZipConstants.DefaultCodePage = Encoding.UTF8.CodePage;
return new ZipFile(stream);
}
}
}

View File

@@ -15,6 +15,7 @@ using System.ComponentModel;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using ICSharpCode.SharpZipLib.Zip;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Support; using OpenRA.Support;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -144,7 +145,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
try try
{ {
using (var stream = File.OpenRead(file)) using (var stream = File.OpenRead(file))
using (var z = ZipFileHelper.Create(stream)) using (var z = new ZipFile(stream))
{ {
foreach (var kv in download.Extract) foreach (var kv in download.Extract)
{ {

View File

@@ -30,8 +30,8 @@ if (!(Test-Path "StyleCop.dll"))
if (!(Test-Path "ICSharpCode.SharpZipLib.dll")) if (!(Test-Path "ICSharpCode.SharpZipLib.dll"))
{ {
echo "Fetching ICSharpCode.SharpZipLib from NuGet." echo "Fetching ICSharpCode.SharpZipLib from NuGet."
./nuget.exe install SharpZipLib -Version 0.86.0 -ExcludeVersion -Verbosity quiet -Source nuget.org ./nuget.exe install SharpZipLib -Version 1.1.0 -ExcludeVersion -Verbosity quiet -Source nuget.org
cp SharpZipLib/lib/20/ICSharpCode.SharpZipLib.dll . cp SharpZipLib/lib/net45/ICSharpCode.SharpZipLib.dll .
rmdir SharpZipLib -Recurse rmdir SharpZipLib -Recurse
} }

View File

@@ -29,8 +29,8 @@ fi
if [ ! -f ICSharpCode.SharpZipLib.dll ]; then if [ ! -f ICSharpCode.SharpZipLib.dll ]; then
echo "Fetching ICSharpCode.SharpZipLib from NuGet" echo "Fetching ICSharpCode.SharpZipLib from NuGet"
../noget.sh SharpZipLib 0.86.0 ../noget.sh SharpZipLib 1.1.0
cp ./SharpZipLib/lib/20/ICSharpCode.SharpZipLib.dll . cp ./SharpZipLib/lib/net45/ICSharpCode.SharpZipLib.dll .
rm -rf SharpZipLib rm -rf SharpZipLib
fi fi