From 5ebe0b53a5f4a33faf138191b254a7d4a5285a5f Mon Sep 17 00:00:00 2001 From: LN Liberda Date: Thu, 27 Aug 2026 08:13:35 +0200 Subject: [PATCH] unbundle/minizip: Ignore Unicode Path Extra Field The fields come from chromium's patches on minizip --- third_party/zlib/google/zip_reader.cc | 34 +-------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/third_party/zlib/google/zip_reader.cc b/third_party/zlib/google/zip_reader.cc index 7b5b28967cfbb..2054e3c09e419 100644 --- a/third_party/zlib/google/zip_reader.cc +++ b/third_party/zlib/google/zip_reader.cc @@ -314,32 +314,6 @@ bool ZipReader::OpenEntry() { bool physical_path_is_directory = false; bool physical_path_is_unsafe = false; - // If an Info-ZIP Unicode Path Extra Field is present, the physical Central - // Directory path is about to be overridden. Decode and normalize it now into - // `entry_.physical_path` so consumers (e.g. Safe Browsing) can still see the - // name that other tools (e.g. Windows Explorer) would use for extraction. - if (info.size_utf8_filename > 0) { - std::u16string physical_path_in_utf16; - if (!base::CodepageToUTF16(entry_.path_in_original_encoding, - configured_encoding, - base::OnStringConversionError::SUBSTITUTE, - &physical_path_in_utf16)) { - LOG(ERROR) << "Cannot convert path from encoding " << configured_encoding; - return false; - } - // Normalize() stores the normalized result in entry_.path; copy it before - // applying the Unicode Path Extra Field below. - Normalize(physical_path_in_utf16); - entry_.physical_path = entry_.path; - physical_path_is_directory = entry_.is_directory; - physical_path_is_unsafe = entry_.is_unsafe; - - // Use the Info-ZIP Unicode Path Extra Field if present. - DCHECK(info.utf8_filename[info.size_utf8_filename] == '\0'); - entry_.path_in_original_encoding = info.utf8_filename; - entry_path_encoding = base::kCodepageUTF8; - } - // Convert path from original encoding to Unicode. std::u16string path_in_utf16; if (!base::CodepageToUTF16(entry_.path_in_original_encoding, @@ -353,13 +327,7 @@ bool ZipReader::OpenEntry() { // Normalize path. Normalize(path_in_utf16); - if (info.size_utf8_filename > 0) { - // Treat an entry as a directory only if both names are directories; - // otherwise callers that analyze file entries should inspect it as a file. - entry_.is_directory = entry_.is_directory && physical_path_is_directory; - // Treat an entry as unsafe if either name is unsafe. - entry_.is_unsafe = entry_.is_unsafe || physical_path_is_unsafe; - } else { + { // In the common case (no Unicode Path Extra Field) the physical path // matches the effective path. entry_.physical_path = entry_.path;