GNU bug report logs - #48902
28.0.50; Directory names containing apostrophes and backticks cause problems

Previous Next

Package: emacs;

Reported by: Rudolf Adamkovič <salutis <at> me.com>

Date: Mon, 7 Jun 2021 14:05:02 UTC

Severity: normal

Found in version 28.0.50

Fixed in version 28.1

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

Full log


Message #44 received at 48902 <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 48902 <at> debbugs.gnu.org, larsi <at> gnus.org, salutis <at> me.com, naofumi <at> yasufuku.dev
Subject: Re: bug#48902: 28.0.50; Directory names containing apostrophes and
 backticks cause problems
Date: Tue, 8 Jun 2021 17:19:44 +0100
On Tue, Jun 08, 2021 at 05:02:25PM +0300, Eli Zaretskii wrote:
> > Date: Tue, 8 Jun 2021 14:00:17 +0100
> > From: Alan Third <alan <at> idiocy.org>
> > Cc: larsi <at> gnus.org, naofumi <at> yasufuku.dev, 48902 <at> debbugs.gnu.org,
> > 	salutis <at> me.com
> > 
> > > It looks like stringWithLispString encodes into UTF-16?  But file
> > > names on macOS should be encoded in UTF-8, and in fact
> > > allocInitFromFile already does TRT when it calls ENCODE_FILE, just
> > > before stringWithLispString is called.  So I think the patch is
> > > correct.
> > > 
> > > (UTF-16 encoding on macOS is for ENCODE_SYSTEM, right?)
> > 
> > I think you're right. But confusingly initByReferencingFile takes an
> > NSString which is a UTF-16 format string, so if I remove all the calls
> > to ENCODE_FILE, stringWithLispString works fine.
> > 
> > I guess we just need to make a note that stringWithLispString cannot
> > handle UTF-8 encoded filenames, unless someone has a smarter solution.
> 
> If you do need a UTF-16 encoded string, then instead of ENCODE_FILE
> you can call code_convert_string_norecord with Qutf_16.  There's no
> need to invent or use a private UTF-16 encoder there, and you also get
> rid of an unnecessary extra UTF-8 encoding as a bonus.

In this case the call to ENCODE_FILE in allocInitFromFile is actually
redundant because image_find_image_fd already calls ENCODE_FILE on the
filename before passing it back. So we get a UTF-8 string no matter
what.

NSString can read in almost anything, and Mattias extended it to read
in multibyte (and ascii) lisp strings, so we don't need a UTF-16 input
specifically. It would probably be nice if NSString was also able to
recognise that a lisp string is UTF-8 and handle that itself, but I
don't think that's really possible, unless we make the assumption that
any unibyte string it's passed will already be ascii or UTF-8.

I don't know if that's a reasonable assumption.

-- 
Alan Third




This bug report was last modified 4 years and 59 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.