ZipArchive Reader: Uses IBM PC character encoding to decode filename and comment if the general purpose bit 11 is not set in the header

This commit is contained in:
srperias@microsoft.com
2018-03-27 13:54:16 -07:00
parent 0cab9bd4b4
commit 04ba6c2d73
2 changed files with 11 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace SharpCompress.Common.Zip.Headers
{
@@ -16,6 +17,11 @@ namespace SharpCompress.Common.Zip.Headers
Version = reader.ReadUInt16();
VersionNeededToExtract = reader.ReadUInt16();
Flags = (HeaderFlags)reader.ReadUInt16();
if ((Flags & HeaderFlags.UTF8) == 0)
{
// IBM Code Page 437
ArchiveEncoding.Default = Encoding.GetEncoding("iso-8859-1");
}
CompressionMethod = (ZipCompressionMethod)reader.ReadUInt16();
LastModifiedTime = reader.ReadUInt16();
LastModifiedDate = reader.ReadUInt16();

View File

@@ -15,6 +15,11 @@ namespace SharpCompress.Common.Zip.Headers
{
Version = reader.ReadUInt16();
Flags = (HeaderFlags)reader.ReadUInt16();
if ((Flags & HeaderFlags.UTF8) == 0)
{
// IBM Code Page 437
ArchiveEncoding.Default = Encoding.GetEncoding("iso-8859-1");
}
CompressionMethod = (ZipCompressionMethod)reader.ReadUInt16();
LastModifiedTime = reader.ReadUInt16();
LastModifiedDate = reader.ReadUInt16();