From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#48902: 28.0.50; Directory names containing apostrophes and backticks cause problems Date: Tue, 8 Jun 2021 20:10:04 +0100 Message-ID: References: <51cb-60bf4900-1dd-2840bc80@23790836> <875yyoo9gy.fsf@gnus.org> <87r1hcmu2q.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="8M9lVMMxROSgWlWt" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26244"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48902@debbugs.gnu.org, Lars Ingebrigtsen , Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= , naofumi@yasufuku.dev To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 08 21:11:25 2021 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 1lqh8G-0006bI-Bw for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Jun 2021 21:11:24 +0200 Original-Received: from localhost ([::1]:49576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lqh8F-0006uw-5h for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Jun 2021 15:11:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lqh7v-0006uZ-61 for bug-gnu-emacs@gnu.org; Tue, 08 Jun 2021 15:11:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48255) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lqh7u-0000Hg-8C for bug-gnu-emacs@gnu.org; Tue, 08 Jun 2021 15:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lqh7u-0003pE-4j for bug-gnu-emacs@gnu.org; Tue, 08 Jun 2021 15:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Jun 2021 19:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48902 X-GNU-PR-Package: emacs Original-Received: via spool by 48902-submit@debbugs.gnu.org id=B48902.162317942514657 (code B ref 48902); Tue, 08 Jun 2021 19:11:02 +0000 Original-Received: (at 48902) by debbugs.gnu.org; 8 Jun 2021 19:10:25 +0000 Original-Received: from localhost ([127.0.0.1]:59801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lqh7F-0003oI-OL for submit@debbugs.gnu.org; Tue, 08 Jun 2021 15:10:25 -0400 Original-Received: from outbound.soverin.net ([116.202.65.218]:50659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lqh7A-0003nx-7I for 48902@debbugs.gnu.org; Tue, 08 Jun 2021 15:10:20 -0400 Original-Received: from smtp.soverin.net (unknown [10.10.3.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 14FFD6062D; Tue, 8 Jun 2021 19:10:10 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.142]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1623179408; bh=HSI3K5uAxU7ZumDRqFMRP0rec7ljhv3L40M2B0j0ys8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gxD7pvkuHQwz5dVcnwU5rOzSQWxmKjTcxbvrFgZMUWvbev0sqb69Pwr3gxFwZUXql p+zd7Yw6585l/056BZQ9NH7waG/Z+UO2tKUvI7VW08upiRNP/+Eww13rUluX7NV2rR TjB78J4et6Xnl4WmZKV8BxLb/I81doO2eenhB9p4RSLlBSBJJL4qfXH+RRM2SGPvgd Zs9SIow78NIvAeWIs3LoopmF9Qjm+QwzGN9bbopiTEA0QoQO+GeprOo+4dWdmMcs8a ObcqWtseIj3Yo4BhHvh7QT3m2DbzXXDtuh0Xfjkb9gtwIguyYQYx4B3dQR/BbMc7Pp ++XRPXh9CRE0w== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.94.2) (envelope-from ) id 1lqh6y-001EJi-TH; Tue, 08 Jun 2021 20:10:04 +0100 Mail-Followup-To: Alan Third , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Lars Ingebrigtsen , naofumi@yasufuku.dev, 48902@debbugs.gnu.org, Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= Content-Disposition: inline In-Reply-To: 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" Xref: news.gmane.io gmane.emacs.bugs:208260 Archived-At: --8M9lVMMxROSgWlWt Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Jun 08, 2021 at 07:45:22PM +0200, Mattias Engdegård wrote: > 8 juni 2021 kl. 14.14 skrev Lars Ingebrigtsen : > > >> It's always possible that stringWithLispString isn't doing the right > >> thing. It's implemented at nsfns.m:3026. I know almost nothing about > >> UTF8/UTF16 so while it looks like it's doing the right thing to me, I > >> could be entirely wrong. > > > > Right -- and that was written by Mattias, so I've added him to the CCs. > > Thank you, but stringWithLispString: is actually fine, unless you > count its inability to produce useful results from wrong input! In my defence it wasn't entirely clear to me that a lisp string returned from ENCODE_FILE was incompatible with stringWithLispString. ;) > The image code seems to be quite confused with respect to whether > the file names being passed around are in encoded form. Until > recently it seems to have worked by pure chance since as long as the > file name encoding is UTF-8 and the low-level code accesses the raw > string data we do get the same result, but at least since > 747a923b9a35 that's no longer the case. Hmm, and as you point out we use "file" further down and it may or may not be encoded, but will probably have the same contents as found, which we know is encoded. Plus it's setting the "name" field in the image, which we probably want to keep as uniform as possible for caching purposes but is otherwise irrelevant. I think the attached should solve this. -- Alan Third --8M9lVMMxROSgWlWt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-image-filename-encoding-issues-in-NS-port-bug-48.patch" >From c2902846c57c55576b1612bf11afaf240994ca70 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Tue, 8 Jun 2021 20:08:34 +0100 Subject: [PATCH] Fix image filename encoding issues in NS port (bug#48902) * src/nsfns.m ([NSString stringWithLispString:]): Clarify usage in comment. * src/nsimage.m ([EmacsImage allocInitFromFile:]): Clarify that the filename is UTF-8 encoded and handle it correctly. --- src/nsfns.m | 3 ++- src/nsimage.m | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nsfns.m b/src/nsfns.m index d14f7b51ea..98801d8526 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -3024,7 +3024,8 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename } @implementation NSString (EmacsString) -/* Make an NSString from a Lisp string. */ +/* Make an NSString from a Lisp string. STRING must not be in an + encoded form (e.g. UTF-8). */ + (NSString *)stringWithLispString:(Lisp_Object)string { /* Shortcut for the common case. */ diff --git a/src/nsimage.m b/src/nsimage.m index fa81a41a51..b0bd52111b 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -252,17 +252,16 @@ @implementation EmacsImage + (instancetype)allocInitFromFile: (Lisp_Object)file { NSImageRep *imgRep; - Lisp_Object found; + Lisp_Object utf8_filename; EmacsImage *image; /* Search bitmap-file-path for the file, if appropriate. */ - found = image_find_image_file (file); - if (!STRINGP (found)) + utf8_filename = image_find_image_file (file); + if (!STRINGP (utf8_filename)) return nil; - found = ENCODE_FILE (found); image = [[EmacsImage alloc] initByReferencingFile: - [NSString stringWithLispString: found]]; + [NSString stringWithUTF8String: SSDATA (utf8_filename)]]; image->bmRep = nil; #ifdef NS_IMPL_COCOA @@ -278,7 +277,7 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; - [image setName: [NSString stringWithLispString: file]]; + [image setName: [NSString stringWithUTF8String: SSDATA (utf8_filename)]]; return image; } -- 2.30.2 --8M9lVMMxROSgWlWt--