From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: awrhygty@outlook.com Newsgroups: gmane.emacs.bugs Subject: bug#65305: 29.1; archive-mode can not handle subfile names encoded with utf-8 Date: Tue, 15 Aug 2023 22:53:01 +0900 Message-ID: References: <83sf8ka6b2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31277"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65305@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 15 15:54:44 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qVuVO-0007wk-U3 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Aug 2023 15:54:43 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVuUm-0006DD-Uf; Tue, 15 Aug 2023 09:54:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVuUk-0006C8-Hu for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 09:54:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qVuUk-00023M-9k for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 09:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qVuUj-0006MJ-Qk for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 09:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: awrhygty@outlook.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Aug 2023 13:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65305 X-GNU-PR-Package: emacs Original-Received: via spool by 65305-submit@debbugs.gnu.org id=B65305.169210759524380 (code B ref 65305); Tue, 15 Aug 2023 13:54:01 +0000 Original-Received: (at 65305) by debbugs.gnu.org; 15 Aug 2023 13:53:15 +0000 Original-Received: from localhost ([127.0.0.1]:35252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVuTz-0006LA-Cx for submit@debbugs.gnu.org; Tue, 15 Aug 2023 09:53:15 -0400 Original-Received: from mail-tyzapc01olkn2063.outbound.protection.outlook.com ([40.92.107.63]:45702 helo=APC01-TYZ-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVuTv-0006Kt-7h for 65305@debbugs.gnu.org; Tue, 15 Aug 2023 09:53:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JiMiPzVovaWamz6UCefPhH7IBKxqVcNdM/viFgb2jTOLAEDIU9LT7mIGwtGhH6ll7u/JfmrGUd5hVOE1ntaaFRHWsO8IAG9hknbvsqh3CeOruqfrnTftmv/Qs46jyHtwnyyRt/47EneJqjXxy1Fb4Dt44T1z1oMzfQdrPG9KzHJobHLFzLaRlz/VbXDaV3MPbocRgTeWUcKktNniX/V7sHBEdGkrtfQYxrDsaSwAkqdSRzQYXDuY/+xJJYUDkhZaDgrsXJ/uuGS7vhYam3nvfap9oX5JmCH3qiyJZXxkyij4Jo/MGN5y06hCPse/p/XLDqod7AFNrDmFcGQMCU8kCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bBKbzr1LSfiBeNOui7wRNRU1yN+QLjd1ty3Bm25x8GA=; b=IepovPwLq5iRKUuOgF4w8N5jirT4oB5WzANnpRKziV+6h6LSfQZLColUl9o/UOMqw9ArUURsVswRk9iJjE1I1RmnPKENkFHlpnOsiefqNtL6XnGpWvgNPOListo40LXiT++wma10jPGkYIMZFw3ZI+A3dcllkKwfUNmUqUrMLyEdgWfat1fsFNrSkWBlcFr5bpO7Piq7Xh+fQCUAH/y3KX84w6+SOTCrkkjnQkEli9x7FrdQEJGLDJVPnKSyh/XRiWR95qaOMv3wsuU6FdwBk/4xe5jlapT41X69nvEp24kHHDBUjd0PnGelqwqs5v6hL+FTUNT0ai5tuH8PskUWNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bBKbzr1LSfiBeNOui7wRNRU1yN+QLjd1ty3Bm25x8GA=; b=pfs69iR7cbv9n5+lmchfXq4lj4NQILdJQq7Dk/nIXXEY/mo0gLm7FVjf/kdYytUYHulnFGNhtGpdzNv5fsG3TcWlyWHywpiCeaRq58dh3csd/Khsn1oHbzsm9XbZEAAqpR5KVXzi5189ojNu/rKGOw4IxEJ2jqu3uSHsoMFcBnzQMkuYJCE6KnmBsLV1zhSFu9LBXv4Dpppeodj9+yqZQtbZKpHrrm5/+ddL80EXN2oI4royD4wYYugd8rI2iMUdKX3VFUq0sjaSYlSrRpiXFnE3zdU4hgVEKw7yMuQTns+PKRwjTwVA9JMgnXOBxPRPNM3Ji+y/cOpF7H9GT7Umxg== Original-Received: from TYZPR01MB3920.apcprd01.prod.exchangelabs.com (2603:1096:400:30::11) by TYZPR01MB3968.apcprd01.prod.exchangelabs.com (2603:1096:400:3a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Tue, 15 Aug 2023 13:53:03 +0000 Original-Received: from TYZPR01MB3920.apcprd01.prod.exchangelabs.com ([fe80::72cf:3224:cab3:a133]) by TYZPR01MB3920.apcprd01.prod.exchangelabs.com ([fe80::72cf:3224:cab3:a133%4]) with mapi id 15.20.6678.022; Tue, 15 Aug 2023 13:53:03 +0000 In-Reply-To: <83sf8ka6b2.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 15 Aug 2023 07:33:35 -0400") X-TMN: [ecHFAa0G+BWKPbpENBXvW9H11zxFf27n] X-ClientProxiedBy: OS0P286CA0138.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:16b::17) To TYZPR01MB3920.apcprd01.prod.exchangelabs.com (2603:1096:400:30::11) X-Microsoft-Original-Message-ID: <86o7j8v2de.fsf@outlook.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR01MB3920:EE_|TYZPR01MB3968:EE_ X-MS-Office365-Filtering-Correlation-Id: f526d46f-2ced-4a68-a472-08db9d96f211 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6eGN0xe6BfA32oSfXAR04CCwpxyUruS0UMLRopcJkboiWJjFF0VOXGeKMPRhvDLIyPEs5GHebg4MRLOspbzg39Wk3CSHx12iPYwpgTfZq5GdmAbDvVfxMAUISGvjQDztWBuSwPhX4mYpxniL5+deK7fBGaPC5tDhnnrzH+OxMdEOUOYtLq4rKNftUPaFWSm8zDbzT8poS/a9X025hpHjGXoDliiHW9PWHT3VFFVaLlabnYgHOdZ74NQFrwn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gOFCT9YkblGsUT/PFt5D7SVlhokx5rPbgaaK+eU25G4VV+4vv50FjzR7AK50xCeExmm 6+Vq3uvwpv6N548vQh7G0Q06dxSziWyxeXEb/Ef0s1dpWTyv7Xp2lRZHnMBSwny54rB8hfyCD4bQgGFAcoDIIziWwL0Ig3Axwo X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f526d46f-2ced-4a68-a472-08db9d96f211 X-MS-Exchange-CrossTenant-AuthSource: TYZPR01MB3920.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2023 13:53:03.6785 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR01MB3968 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267489 Archived-At: Eli Zaretskii writes: >> From: awrhygty@outlook.com >> Date: Tue, 15 Aug 2023 13:31:16 +0900 >> >> >> With python 3.10, ZIP archive can be created with: >> python -m zipfile -c ARCHIVE.zip subfile >> >> If the subfile name contains non-ASCII characters, they are encoded with >> utf-8 in anyway. Such subfile names are decoded with local language >> encoding(cp932 for Japanese Windows OS) in archive-mode. >> >> For example, archive 一.txt in test.zip with python: >> python -m zipfile -c test.zip 一.txt >> The subfile name is shown as 荳\200.txt in archive-mode buffer and the >> entry can not be extracted. > > Is there any way of distinguishing these Python-created ZIP archives > from ZIP archives created by other Windows programs? > > Emacs by default assumes that file names in a ZIP archive created by a > Windows program are encoded in the console codepage, and it enforces > using that encoding for file names when the "creator" of the ZIP > archive indicates the archive was created by Windows programs such as > InfoZip's zip.exe and the File Explorer. In my testing, zip archives > created by Python as above record the "creator" as number 0 (zero), > which is identical to what InfoZip does. So, unless someone explains > how to distinguish these zip archives from those created by InfoZip, I > don't see how can Emacs know whether to use the InfoZip heuristics or > the Python heuristics. Without the InfoZip/File Explorer heuristics > we have in arc-mode.el today, Emacs on Windows would be completely > unable to support non-ASCII file names in ZIP archives. There is a bit flag indicating that the subfile name is encoded with utf-8. Bytes 6-7 in local file header or bytes 8-9 in central directory header are general purpose bit flag. And bit 11 of the flag represents file encoding flag(1 for utf-8 encoding). I guess unzip.exe does not support utf-8 encoded subfile name. Writing batch file with utf-8 encoding: c:\Emacs\emacs-29.1\bin\unzip.exe test.zip 一.txt and run with chcp 932, 荳\200.txt is extracted. With chcp 65001, extraction failed. Writing batch file with cp932 encoding:(same as above) c:\Emacs\emacs-29.1\bin\unzip.exe test.zip 一.txt and run with chcp 65001, 荳\200.txt is extracted. With chcp 932, extraction failed. This is not an ideal behavior, but extraction to STDOUT may work. To the contrary, 7z.exe extracts 一.txt correctly. If batch file is encoded with utf-8, it works with chcp 65001. If batch file is encoded with cp932, it works with chcp 932.