Replacing SharpZipLib by DtoNetZip

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros 2012-09-05 18:47:59 -07:00
parent b1b921c2a2
commit cd7fb75f65
10 changed files with 18215 additions and 78 deletions

View File

@ -63,6 +63,12 @@ Website: http://dlr.codeplex.com
Copyright: Copyright (c) Microsoft Corporation
License: Apache Software Foundation License 2.0
DotNetZip
-----
Website: http://dotnetzip.codeplex.com/
Copyright:
License: MS-PL
Eric Meyer's Reset CSS
-----
Website: http://meyerweb.com/eric/tools/css/reset/
@ -179,12 +185,6 @@ Copyright: Copyright (c) 2002-2007 NUnit.org
Portions Copyright (c) 2002-2008 Charlie Poole or Copyright (c) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright (c) 2000-2002 Philip A. Craig
License: Derived from zlib: http://nunit.org/index.php?p=license&r=2.4
SharpZipLib
-----
Website: http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
Copyright: Copyright (c) 2000-2009 IC#Code
License: GPLv2 with Classpath Exception: http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
SpecFlow
-----
Website: http://www.specflow.org/

BIN
lib/dotnetzip/Ionic.Zip.dll Normal file

Binary file not shown.

18132
lib/dotnetzip/Ionic.Zip.xml Normal file

File diff suppressed because it is too large Load Diff

33
lib/dotnetzip/License.txt Normal file
View File

@ -0,0 +1,33 @@
Microsoft Public License (Ms-PL)
This license governs use of the accompanying software, the DotNetZip library ("the software"). If you use the software, you accept this license. If you do not accept the license, do not use the software.
1. Definitions
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
A "contribution" is the original software, or any additions or changes to the software.
A "contributor" is any person that distributes its contribution under this license.
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.

View File

@ -1,10 +0,0 @@
License
The library is released under the GPL with the following exception:
Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination.
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
Note The exception is changed to reflect the latest GNU Classpath exception. Older versions of #ziplib did have another exception, but the new one is clearer and it doesn't break compatibility with the old one.
Bottom line In plain English this means you can use this library in commercial closed-source applications.

View File

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.SharpZipLib.Zip;
using Ionic.Zip;
using NUnit.Framework;
using Orchard.Environment.Configuration;
using Orchard.FileSystems.Media;
@ -169,46 +169,21 @@ namespace Orchard.Tests.Modules.Media.Services {
private MemoryStream CreateZipMemoryStream() {
// Setup memory stream with zip archive for more complex scenarios
MemoryStream memoryStream = new MemoryStream();
ZipOutputStream zipOut = new ZipOutputStream(memoryStream);
using (ZipFile zipOut = new ZipFile()) {
zipOut.PutNextEntry(new ZipEntry(TextFileName));
zipOut.Write(new byte[] { 0x01 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(WebconfigFileName));
zipOut.Write(new byte[] { 0x02 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(DllFileName));
zipOut.Write(new byte[] { 0x03 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(ZipFileName));
zipOut.Write(new byte[] { 0x04 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(NoExtensionFileName));
zipOut.Write(new byte[] { 0x05 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(PaddedWebconfigFileName));
zipOut.Write(new byte[] { 0x06 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(FinalDottedWebconfigFileName));
zipOut.Write(new byte[] { 0x07 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(PaddedTextFileName));
zipOut.Write(new byte[] { 0x08 }, 0, 1);
zipOut.CloseEntry();
zipOut.PutNextEntry(new ZipEntry(FinalDottedTextFileName));
zipOut.Write(new byte[] { 0x09 }, 0, 1);
zipOut.CloseEntry();
zipOut.Close();
zipOut.AddEntry(TextFileName, new byte[] { 0x01 });
zipOut.AddEntry(WebconfigFileName, new byte[] { 0x02 });
zipOut.AddEntry(DllFileName, new byte[] { 0x03 });
zipOut.AddEntry(ZipFileName, new byte[] { 0x04 });
zipOut.AddEntry(NoExtensionFileName, new byte[] { 0x05 });
zipOut.AddEntry(PaddedWebconfigFileName, new byte[] { 0x06 });
zipOut.AddEntry(FinalDottedWebconfigFileName, new byte[] { 0x07 });
zipOut.AddEntry(PaddedTextFileName, new byte[] { 0x08 });
zipOut.AddEntry(FinalDottedTextFileName, new byte[] { 0x09 });
zipOut.Save(memoryStream);
}
return new MemoryStream(memoryStream.ToArray());
}

View File

@ -72,14 +72,13 @@
<Reference Include="FluentPath">
<HintPath>..\..\lib\fluentpath\FluentPath.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\sharpziplib\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\nhibernate\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip">
<HintPath>..\..\lib\dotnetzip\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="IronRuby, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\dlr\IronRuby.dll</HintPath>

View File

@ -21,6 +21,10 @@
</UpgradeBackupLocation>
<TargetFrameworkProfile />
<UseIISExpress>false</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -42,10 +46,8 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\sharpziplib\ICSharpCode.SharpZipLib.dll</HintPath>
<Private>True</Private>
<Reference Include="Ionic.Zip">
<HintPath>..\..\..\..\lib\dotnetzip\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using ICSharpCode.SharpZipLib.Zip;
using Ionic.Zip;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.FileSystems.Media;
@ -293,21 +293,27 @@ namespace Orchard.Media.Services {
Argument.ThrowIfNullOrEmpty(targetFolder, "targetFolder");
Argument.ThrowIfNull(zipStream, "zipStream");
var fileInflater = new ZipInputStream(zipStream);
ZipEntry entry;
// We want to preserve whatever directory structure the zip file contained instead
// of flattening it.
// The API below doesn't necessarily return the entries in the zip file in any order.
// That means the files in subdirectories can be returned as entries from the stream
// before the directories that contain them, so we create directories as soon as first
// file below their path is encountered.
while ((entry = fileInflater.GetNextEntry()) != null) {
if (!entry.IsDirectory && !string.IsNullOrEmpty(entry.Name)) {
using (var fileInflater = ZipFile.Read(zipStream)) {
// We want to preserve whatever directory structure the zip file contained instead
// of flattening it.
// The API below doesn't necessarily return the entries in the zip file in any order.
// That means the files in subdirectories can be returned as entries from the stream
// before the directories that contain them, so we create directories as soon as first
// file below their path is encountered.
foreach (ZipEntry entry in fileInflater) {
if (entry == null) {
continue;
}
// skip disallowed files
if (FileAllowed(entry.Name, false)) {
string fullFileName = _storageProvider.Combine(targetFolder, entry.Name);
_storageProvider.TrySaveStream(fullFileName, fileInflater);
if (!entry.IsDirectory && !string.IsNullOrEmpty(entry.FileName)) {
// skip disallowed files
if (FileAllowed(entry.FileName, false)) {
string fullFileName = _storageProvider.Combine(targetFolder, entry.FileName);
using (var stream = entry.OpenReader()) {
_storageProvider.TrySaveStream(fullFileName, stream);
}
}
}
}
}