View Issue Details

IDProjectCategoryView StatusLast Update
0036673FPCPackagespublic2020-02-10 08:27
ReporterPetr-K Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0036673: Paszlib Unzipper - EFS language encoding UTF-8 implementation
DescriptionWhen zip entry is read and bit "Language encoding flag (EFS)" is set, then codepage utf-8 is assigned to readed string.

Patch is included.

Tested on linux utf-8, iso-8859-2 and windows.
TagsNo tags attached.
Fixed in Revision44125
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Petr-K

2020-02-07 08:31

reporter  

zipper.patch (1,700 bytes)   
Index: zipper.pp
===================================================================
--- zipper.pp	(revision 44124)
+++ zipper.pp	(working copy)
@@ -34,6 +34,7 @@
   ZIP64_HEADER_ID                            = $0001;
   // infozip unicode path
   INFOZIP_UNICODE_PATH_ID                    = $7075;
+  EFS_LANGUAGE_ENCODING_FLAG                 = $800;
 
 const
   OS_FAT  = 0; //MS-DOS and OS/2 (FAT/VFAT/FAT32)
@@ -2275,7 +2276,7 @@
 
 procedure TUnZipper.ReadZipHeader(Item: TFullZipFileEntry; out AMethod: Word);
 Var
-  S : String;
+  S : RawByteString;
   U : UTF8String;
   D : TDateTime;
   ExtraFieldHdr: Extensible_Data_Field_Header_Type;
@@ -2295,6 +2296,8 @@
       Item.FBitFlags:=Bit_Flag;
       SetLength(S,Filename_Length);
       FZipStream.ReadBuffer(S[1],Filename_Length);
+      if Bit_Flag and EFS_LANGUAGE_ENCODING_FLAG <> 0 then
+        SetCodePage(S, CP_UTF8, False);
       Item.ArchiveFileName:=S;
       Item.DiskFileName:=S;
       SavePos:=FZipStream.Position; //after filename, before extra fields
@@ -2506,7 +2509,7 @@
   Zip64Field: Zip64_Extended_Info_Field_Type;
   NewNode   : TFullZipFileEntry;
   D : TDateTime;
-  S : String;
+  S : RawByteString;
   U : UTF8String;
   // infozip unicode path
   Infozip_unicode_path_ver : byte; // always 1
@@ -2561,6 +2564,8 @@
       NewNode.FBitFlags:=Bit_Flag;
       SetLength(S,Filename_Length);
       FZipStream.ReadBuffer(S[1],Filename_Length);
+      if Bit_Flag and EFS_LANGUAGE_ENCODING_FLAG <> 0 then
+        SetCodePage(S, CP_UTF8, False);
       SavePos:=FZipStream.Position; //After fixed part of central directory...
       // and the filename; before any extra field(s)
       NewNode.ArchiveFileName:=S;
zipper.patch (1,700 bytes)   

Michael Van Canneyt

2020-02-07 09:47

administrator   ~0120913

Applied, thank you very much !

Issue History

Date Modified Username Field Change
2020-02-07 08:31 Petr-K New Issue
2020-02-07 08:31 Petr-K File Added: zipper.patch
2020-02-07 09:47 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-02-07 09:47 Michael Van Canneyt Status new => resolved
2020-02-07 09:47 Michael Van Canneyt Resolution open => fixed
2020-02-07 09:47 Michael Van Canneyt Fixed in Version => 3.3.1
2020-02-07 09:47 Michael Van Canneyt Fixed in Revision => 44125
2020-02-07 09:47 Michael Van Canneyt FPCTarget => 3.2.0
2020-02-07 09:47 Michael Van Canneyt Note Added: 0120913
2020-02-10 08:27 Petr-K Status resolved => closed