diff --git a/SOURCES/0001-Using-libnatspec-to-correctly-decode-non-ASCII.patch b/SOURCES/0001-Using-libnatspec-to-correctly-decode-non-ASCII.patch new file mode 100644 index 0000000..ce3e10e --- /dev/null +++ b/SOURCES/0001-Using-libnatspec-to-correctly-decode-non-ASCII.patch @@ -0,0 +1,104 @@ +From 0bb3986583a1daff2466c318473191d6cbd63adb Mon Sep 17 00:00:00 2001 +From: Sergey Cherevko +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 + #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 &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 + diff --git a/SPECS/p7zip.spec b/SPECS/p7zip.spec index 138f55c..f70f1b9 100644 --- a/SPECS/p7zip.spec +++ b/SPECS/p7zip.spec @@ -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 - 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 - 16.02-21 - Rebuilt for MSVSphere 9.2