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


View this message in rfc822 format

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: bug#48902: 28.0.50; Directory names containing apostrophes and backticks cause problems
Date: Tue, 8 Jun 2021 14:00:17 +0100
On Tue, Jun 08, 2021 at 03:37:51PM +0300, Eli Zaretskii wrote:
> > Date: Tue, 8 Jun 2021 13:12:56 +0100
> > From: Alan Third <alan <at> idiocy.org>
> > Cc: 48902 <at> debbugs.gnu.org, Rudolf Adamkovič <salutis <at> me.com>,
> >  naofumi <at> yasufuku.dev
> > 
> > On Tue, Jun 08, 2021 at 01:57:01PM +0200, Lars Ingebrigtsen wrote:
> > > naofumi <at> yasufuku.dev <naofumi <at> yasufuku.dev> writes:
> > > 
> > > > diff --git a/src/nsimage.m b/src/nsimage.m
> > > > index fa81a41a51..8c7a3d9a09 100644
> > > > --- a/src/nsimage.m
> > > > +++ b/src/nsimage.m
> > > > @@ -262,7 +262,7 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file
> > > >    found = ENCODE_FILE (found);
> > > >  
> > > >    image = [[EmacsImage alloc] initByReferencingFile:
> > > > -                     [NSString stringWithLispString: found]];
> > > > +                     [NSString stringWithUTF8String: SSDATA (found)]];
> > > 
> > > Hm...  I'm not very familiar at all with the Objective C code here...
> > > but shouldn't "found" here be a Lisp string so that stringWithLispString
> > > would do the right thing?
> > 
> > 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.
> 
> 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.

-- 
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.