From 981ac0f92ffbbaf48fc04d25f4878769897f97d4 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Wed, 9 Oct 2024 21:46:02 +0200 Subject: [PATCH] ZIP: Improve encoding detection by only feeding the filename to ICU Before the string contained full paths, breaking the detection logic because most paths are ASCII --- src/filesystem_zip.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filesystem_zip.cpp b/src/filesystem_zip.cpp index eee40b0e36..8fab26ec17 100644 --- a/src/filesystem_zip.cpp +++ b/src/filesystem_zip.cpp @@ -83,8 +83,8 @@ ZipFilesystem::ZipFilesystem(std::string base_path, FilesystemView parent_fs, St int items = 0; while (ReadCentralDirectoryEntry(zip_is, filepath, entry, is_utf8)) { // Only consider Non-ASCII & Non-UTF8 for encoding detection - // Skip directories, files already contain the paths - if (is_utf8 || filepath.back() == '/' || Utils::StringIsAscii(filepath)) { + // Directories are skipped as most of them are usually ASCII and do not help with the detection + if (is_utf8 || filepath.back() == '/' || Utils::StringIsAscii(std::get<1>(FileFinder::GetPathAndFilename(filepath)))) { continue; } // Codepath will be only entered by Windows "compressed folder" ZIPs (uses local encoding) and