Using libnatspec to correctly decode non-ASCII filenames zipped on Windows.

i9e changed/i9e/p7zip-16.02-21.el9.inferit
Sergey Cherevko 1 year ago
parent f9d1b32770
commit e05f7a9303
Signed by: scherevko
GPG Key ID: D87CBBC16D2E4A72

@ -0,0 +1,104 @@
From 0bb3986583a1daff2466c318473191d6cbd63adb Mon Sep 17 00:00:00 2001
From: Sergey Cherevko <s.cherevko@msvsphere-os.ru>
Date: Fri, 19 Jan 2024 16:35:06 +0300
Subject: [PATCH] Using libnatspec to correctly decode non-ASCII filenames
zipped on Windows.
---
CPP/7zip/Archive/Zip/ZipItem.cpp | 44 +++++++-------------------------
makefile.linux_amd64_asm | 2 +-
makefile.machine | 2 +-
3 files changed, 11 insertions(+), 37 deletions(-)
diff --git a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp
index 12bc8ad..16a4dbe 100644
--- a/CPP/7zip/Archive/Zip/ZipItem.cpp
+++ b/CPP/7zip/Archive/Zip/ZipItem.cpp
@@ -1,5 +1,5 @@
// Archive/ZipItem.cpp
-
+#include <natspec.h>
#include "StdAfx.h"
#include "../../../../C/CpuArch.h"
@@ -208,43 +208,17 @@ void CItem::GetUnicodeString(UString &res, const AString &s, bool isComment, boo
bool isUtf8 = IsUtf8();
bool ignore_Utf8_Errors = true;
- if (!isUtf8)
- {
- {
- const unsigned id = isComment ?
- NFileHeader::NExtraID::kIzUnicodeComment:
- NFileHeader::NExtraID::kIzUnicodeName;
- const CObjectVector<CExtraSubBlock> &subBlocks = GetMainExtra().SubBlocks;
-
- FOR_VECTOR (i, subBlocks)
- {
- const CExtraSubBlock &sb = subBlocks[i];
- if (sb.ID == id)
- {
- AString utf;
- if (sb.ExtractIzUnicode(CrcCalc(s, s.Len()), utf))
- if (ConvertUTF8ToUnicode(utf, res))
- return;
- break;
- }
- }
- }
-
- if (useSpecifiedCodePage)
- isUtf8 = (codePage == CP_UTF8);
- #ifdef _WIN32
- else if (GetHostOS() == NFileHeader::NHostOS::kUnix)
- {
- /* Some ZIP archives in Unix use UTF-8 encoding without Utf8 flag in header.
- We try to get name as UTF-8.
- Do we need to do it in POSIX version also? */
- isUtf8 = true;
- ignore_Utf8_Errors = false;
- }
- #endif
+ if (!isUtf8) {
+ const char *oem_charset = natspec_get_charset_by_locale(NATSPEC_DOSCS, "");
+ char *p = natspec_convert(s.Ptr(), NULL, oem_charset, 0);
+ AString utf = p;
+ free(p);
+ if (ConvertUTF8ToUnicode(utf, res))
+ return;
}
+
if (isUtf8)
if (ConvertUTF8ToUnicode(s, res) || ignore_Utf8_Errors)
return;
diff --git a/makefile.linux_amd64_asm b/makefile.linux_amd64_asm
index 075c6a8..3de8ccf 100644
--- a/makefile.linux_amd64_asm
+++ b/makefile.linux_amd64_asm
@@ -19,7 +19,7 @@ ASM=yasm -f elf -m amd64 -Dx64
PRE_COMPILED_HEADER=StdAfx.h.gch
-LOCAL_LIBS=-lpthread
+LOCAL_LIBS=-lpthread -lnatspec
LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
CPU=x64
diff --git a/makefile.machine b/makefile.machine
index 9e34c34..054edde 100644
--- a/makefile.machine
+++ b/makefile.machine
@@ -15,7 +15,7 @@ CC=gcc
CC_SHARED=-fPIC
LINK_SHARED=-fPIC -shared
-LOCAL_LIBS=-lpthread
+LOCAL_LIBS=-lpthread -lnatspec
LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
OBJ_CRC32=$(OBJ_CRC32_C)
--
2.39.3

@ -7,7 +7,7 @@
Summary: Very high compression ratio file archiver
Name: p7zip
Version: 16.02
Release: 21%{?dist}
Release: 21%{?dist}.inferit
# Files under C/Compress/Lzma/ are dual LGPL or CPL
License: LGPLv2 and (LGPLv2+ or CPL)
URL: http://p7zip.sourceforge.net/
@ -31,11 +31,14 @@ Patch11: 14-Fix-g++-warning.patch
Patch12: gcc10-conversion.patch
Patch13: 0001-fix-data-null-pointer.patch
Patch14: 0001-fix-out-of-mem.patch
#MSVSphere
Patch100: 0001-Using-libnatspec-to-correctly-decode-non-ASCII.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: cmake
BuildRequires: libnatspec-devel
%if %{with gui}
# for 7zG GUI
%if 0%{?rhel} && 0%{?rhel} <= 7
@ -180,6 +183,10 @@ make test
%changelog
* Fri Jan 19 2024 Sergey Cherevko <s.cherevko@msvsphere-os.ru> - 16.02-21.inferit
- Using libnatspec to correctly decode non-ASCII filenames zipped on Windows.
- Rebuilt for MSVSphere 9.3
* Tue Jul 25 2023 Arkady L. Shane <ashejn@msvsphere.ru> - 16.02-21
- Rebuilt for MSVSphere 9.2

Loading…
Cancel
Save