View Issue Details

IDProjectCategoryView StatusLast Update
0036690FPCPackagespublic2020-03-04 16:40
ReporterPetr-KAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Buildr44144 
Target VersionFixed in Version3.3.1 
Summary0036690: Paszlib Zipper - EFS language encoding UTF-8 implementation
DescriptionPatch converts ZFileName to utf-8 and sets bit 11 language encoding in Flags.
Can be enabled by property UseLanguageEncoding.
TagsNo tags attached.
Fixed in Revision44149
FPCOldBugId
FPCTarget3.2.0
Attached Files
  • zipper.patch (1,881 bytes)
    Index: packages/paszlib/src/zipper.pp
    ===================================================================
    --- packages/paszlib/src/zipper.pp	(revision 44144)
    +++ packages/paszlib/src/zipper.pp	(working copy)
    @@ -72,7 +72,6 @@
        Local_File_Header_Type = Packed Record //1 per zipped file
          Signature              :  LongInt; //4 bytes
          Extract_Version_Reqd   :  Word; //if zip64: >= 45
    -     {$warning TODO implement EFS/language enooding using UTF-8}
          Bit_Flag               :  Word; //"General purpose bit flag in PKZip appnote
          Compress_Method        :  Word;
          Last_Mod_Time          :  Word;
    @@ -434,6 +433,7 @@
         FOnEndOfFile    : TOnEndOfFileEvent;
         FOnStartFile    : TOnStartFileEvent;
         FCurrentCompressor : TCompressor;
    +    FUseLanguageEncoding: Boolean;
         function CheckEntries: Integer;
         procedure SetEntries(const AValue: TZipFileEntries);
       Protected
    @@ -488,6 +488,8 @@
         Property InMemSize : Int64 Read FInMemSize Write FInMemSize;
         Property Entries : TZipFileEntries Read FEntries Write SetEntries;
         Property Terminated : Boolean Read FTerminated;
    +    // EFS/language enooding using UTF-8
    +    Property UseLanguageEncoding : Boolean Read FUseLanguageEncoding Write FUseLanguageEncoding;
       end;
     
       { TFullZipFileEntry }
    @@ -1605,12 +1610,16 @@
     var
       IsZip64           : boolean; //Must the local header be in zip64 format?
       // Separate from zip64 status of entire zip file.
    -  ZFileName         : String;
    +  ZFileName         : RawByteString;
     Begin
       ZFileName := Item.ArchiveFileName;
       IsZip64 := false;
       With LocalHdr do
         begin
    +    if FUseLanguageEncoding then begin
    +      SetCodePage(ZFileName, CP_UTF8, True);
    +      Bit_Flag := Bit_Flag or EFS_LANGUAGE_ENCODING_FLAG;
    +    end;
         FileName_Length := Length(ZFileName);
         Crc32 := ACRC;
         if LocalZip64Fld.Original_Size > 0 then
    
    zipper.patch (1,881 bytes)

Activities

Petr-K

2020-02-11 10:34

reporter  

zipper.patch (1,881 bytes)
Index: packages/paszlib/src/zipper.pp
===================================================================
--- packages/paszlib/src/zipper.pp	(revision 44144)
+++ packages/paszlib/src/zipper.pp	(working copy)
@@ -72,7 +72,6 @@
    Local_File_Header_Type = Packed Record //1 per zipped file
      Signature              :  LongInt; //4 bytes
      Extract_Version_Reqd   :  Word; //if zip64: >= 45
-     {$warning TODO implement EFS/language enooding using UTF-8}
      Bit_Flag               :  Word; //"General purpose bit flag in PKZip appnote
      Compress_Method        :  Word;
      Last_Mod_Time          :  Word;
@@ -434,6 +433,7 @@
     FOnEndOfFile    : TOnEndOfFileEvent;
     FOnStartFile    : TOnStartFileEvent;
     FCurrentCompressor : TCompressor;
+    FUseLanguageEncoding: Boolean;
     function CheckEntries: Integer;
     procedure SetEntries(const AValue: TZipFileEntries);
   Protected
@@ -488,6 +488,8 @@
     Property InMemSize : Int64 Read FInMemSize Write FInMemSize;
     Property Entries : TZipFileEntries Read FEntries Write SetEntries;
     Property Terminated : Boolean Read FTerminated;
+    // EFS/language enooding using UTF-8
+    Property UseLanguageEncoding : Boolean Read FUseLanguageEncoding Write FUseLanguageEncoding;
   end;
 
   { TFullZipFileEntry }
@@ -1605,12 +1610,16 @@
 var
   IsZip64           : boolean; //Must the local header be in zip64 format?
   // Separate from zip64 status of entire zip file.
-  ZFileName         : String;
+  ZFileName         : RawByteString;
 Begin
   ZFileName := Item.ArchiveFileName;
   IsZip64 := false;
   With LocalHdr do
     begin
+    if FUseLanguageEncoding then begin
+      SetCodePage(ZFileName, CP_UTF8, True);
+      Bit_Flag := Bit_Flag or EFS_LANGUAGE_ENCODING_FLAG;
+    end;
     FileName_Length := Length(ZFileName);
     Crc32 := ACRC;
     if LocalZip64Fld.Original_Size > 0 then
zipper.patch (1,881 bytes)

Michael Van Canneyt

2020-02-11 10:45

administrator   ~0121011

Checked & applied, thank you very much for the patch !

Issue History

Date Modified Username Field Change
2020-02-11 10:34 Petr-K New Issue
2020-02-11 10:34 Petr-K File Added: zipper.patch
2020-02-11 10:45 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-02-11 10:45 Michael Van Canneyt Status new => resolved
2020-02-11 10:45 Michael Van Canneyt Resolution open => fixed
2020-02-11 10:45 Michael Van Canneyt Fixed in Version => 3.3.1
2020-02-11 10:45 Michael Van Canneyt Fixed in Revision => 44149
2020-02-11 10:45 Michael Van Canneyt FPCTarget => 3.2.0
2020-02-11 10:45 Michael Van Canneyt Note Added: 0121011
2020-03-04 16:40 Petr-K Status resolved => closed