From: naofumi@yasufuku.dev <naofumi@yasufuku.dev>
To: "Eli Zaretskii" <eliz@gnu.org>
Cc: 48902@debbugs.gnu.org, "Mattias Engdegård" <mattiase@acm.org>,
larsi@gnus.org, salutis@me.com, alan@idiocy.org
Subject: bug#48902: 28.0.50; Directory names containing apostrophes and backticks cause problems
Date: Tue, 08 Jun 2021 21:13:13 +0200 [thread overview]
Message-ID: <425b-60bfc180-2cf-61d54780@49549503> (raw)
In-Reply-To: <83h7i8dxta.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]
On Tuesday, June 08, 2021 20:18 CEST, Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Mattias Engdegård <mattiase@acm.org>
> > Date: Tue, 8 Jun 2021 19:45:22 +0200
> > Cc: 48902@debbugs.gnu.org, Alan Third <alan@idiocy.org>,
> > Rudolf Adamkovič <salutis@me.com>, naofumi@yasufuku.dev
> >
> > The quick fix of reverting to stringWithUTF8String: will work, but the real problem is that we have no control of the encodedness of lisp strings being passed around.
>
> The usual technique in these cases is to keep Lisp strings unencoded,
> encode them when passing to the low-level C functions, and pass to
> those functions only the pointer to the string's data.
>
> In those rare cases when you really need to pass a Lisp string that is
> an encoded file name, call the argument "encoded_file" or somesuch.
> But these cases should be rare exceptions.
>
>
I agree that [NSString stringWithLispString:] is working as expected,
and it is not the real problem.
For example, another patch using STRING_SET_MULTIBYTE() is here.
This looks still just a quick fix and bit weired, though..
attachments:
0001-Fix-to-show-images-with-non-ascii-filename-STRING_SET_MULTIBYTE.patch
image-non-ascii-filename-STRING_SET_MULTIBYTE-macos.png
image-non-ascii-filename-STRING_SET_MULTIBYTE-linux.png
On the other hand, I cannot find out that non-UTF-8 filename coding is
really needed on macOS. It might be over-engineered thing, and just an overhead.
Regards,
--Naofumi
[-- Attachment #2: image-non-ascii-filename-STRING_SET_MULTIBYTE-macos.png --]
[-- Type: image/png, Size: 234036 bytes --]
[-- Attachment #3: 0001-Fix-to-show-images-with-non-ascii-filename-STRING_SET_MULTIBYTE.patch --]
[-- Type: application/octet-stream, Size: 1676 bytes --]
From 0b18100ada3a16e667684383150c4f4d7848e5ce Mon Sep 17 00:00:00 2001
From: Naofumi Yasufuku <naofumi@yasufuku.dev>
Date: Wed, 9 Jun 2021 02:10:43 +0900
Subject: [PATCH] Fix to show images with non-ascii filename on macOS
* src/image.c (image_find_image_fd): Indicate 'file_found' Lisp_String
as multibyte if 'file' or 'search_path' is multibyte Lisp_String.
Without this special care, string_to_multibyte() call in
[NSString stringWithLispString:] attempts to convert the multibyte
filename (UTF-8 by default) to multybyte string unintentionally.
(Bug#48902)
* src/nsimage.m ([EmacsImage allocInitFromFile:]): Remove redundant
ENCODE_FILE() which is done by image_find_image_fd().
---
src/image.c | 2 ++
src/nsimage.m | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/image.c b/src/image.c
index b34dc3e916..f7204af873 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3156,6 +3156,8 @@ image_find_image_fd (Lisp_Object file, int *pfd)
if (fd >= 0 || fd == -2)
{
file_found = ENCODE_FILE (file_found);
+ if (STRING_MULTIBYTE (search_path) || STRING_MULTIBYTE (file))
+ STRING_SET_MULTIBYTE (file_found);
if (fd == -2)
{
/* The file exists locally, but has a file name handler.
diff --git a/src/nsimage.m b/src/nsimage.m
index fa81a41a51..5e5960de90 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -259,7 +259,6 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file
found = image_find_image_file (file);
if (!STRINGP (found))
return nil;
- found = ENCODE_FILE (found);
image = [[EmacsImage alloc] initByReferencingFile:
[NSString stringWithLispString: found]];
--
2.31.1
[-- Attachment #4: image-non-ascii-filename-STRING_SET_MULTIBYTE-linux.png --]
[-- Type: image/png, Size: 82170 bytes --]
next prev parent reply other threads:[~2021-06-08 19:13 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-07 13:32 bug#48902: 28.0.50; Directory names containing apostrophes and backticks cause problems Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-07 14:08 ` Lars Ingebrigtsen
2021-06-07 14:15 ` Eli Zaretskii
2021-06-07 14:24 ` Lars Ingebrigtsen
2021-06-07 14:36 ` Eli Zaretskii
2021-06-07 14:13 ` Eli Zaretskii
2021-06-08 22:21 ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-08 10:39 ` naofumi
2021-06-08 11:57 ` Lars Ingebrigtsen
2021-06-08 12:12 ` Alan Third
2021-06-08 12:14 ` Lars Ingebrigtsen
2021-06-08 17:45 ` Mattias Engdegård
2021-06-08 18:18 ` Eli Zaretskii
2021-06-08 19:13 ` naofumi [this message]
2021-06-08 20:08 ` Mattias Engdegård
2021-06-08 19:10 ` Alan Third
2021-06-08 19:52 ` Mattias Engdegård
2021-06-08 20:33 ` Alan Third
2021-06-09 11:40 ` Mattias Engdegård
2021-06-09 15:19 ` Alan Third
2021-06-11 22:09 ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-09 11:56 ` Eli Zaretskii
2021-06-08 18:17 ` Mattias Engdegård
2021-06-08 12:37 ` Eli Zaretskii
2021-06-08 13:00 ` Alan Third
2021-06-08 14:02 ` Eli Zaretskii
2021-06-08 16:19 ` Alan Third
2021-06-08 18:09 ` Eli Zaretskii
2021-06-08 19:24 ` Alan Third
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=425b-60bfc180-2cf-61d54780@49549503 \
--to=naofumi@yasufuku.dev \
--cc=48902@debbugs.gnu.org \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
--cc=mattiase@acm.org \
--cc=salutis@me.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).