Subject: Re: bug#18310: 24.3.93; relative links don't work in eww and Windows 7

From: [email-masked] (João Távora)
Date: Fri, 22 Aug 2014 11:26:03 +0100

Eli Zaretskii <[email-masked]> writes:

>> >> Finally
>> >> 
>> >>    (let ((default-directory "\\\\"))
>> >>      (expand-file-name "../" "/something/bla"))
>> >> 
>> >> Crashed the Emacs process on my machine.
>> >
>> > It's not a crash, it's a deliberate abort.  "\\\\" (i.e., 2
>> > backslashes in a row without anything after that) is an invalid file
>> > name on Windows.
>> 
>> Would signalling an error be very wrong, does the process really need to
>> be aborted?
>
> Yes.  This is a deliberate trap for code either in Emacs itself or in
> Lisp applications that uses such invalid default-directory values.

But it really seems arbitrary, since

   (let ((default-directory "><>:\"/\|?*"))
     (expand-file-name "../" "/something/bla"))

contains very much an invalid `default-directory' value and does not
"deliberately abort". It returs "z:/something" as always (i.e
default-directory is fully ignored).

>> I mean unprotected code may easily lead to that invalid case.
>
> Not "easily", no.  Usually, default-directory comes from some file or
> buffer.

It can very well be lexically bound to something that eventually
evaluates to "////". For example to temporarily work on a directory in a
Lisp program. Emacs own lisp code seems littered with (let
((default-directory ...)), just grep for it.

> But if some code does use that, we want to catch it red-handed,
> because there's no way to know what other damage it can do down the
> road.

To be clear, I fully support your "early abort" cause. But one thing is
aborting the command the other thing is aborting the process. I think
you should do the latter if it's the Emacs' internals that caused the
(supposedly unrecoverable) error. But you should do the former if it was
the user's Lisp program that provided incorrect input.

I've looked at the code and expand-file-name is a woolly mammoth so
maybe that's hard to do, but it would be the right thing IMO.

> Emacs is not mission-critical software.  If it were, then I'd agree
> with you (I happen to develop mission-critical software for a living).

Me too. In Lisp. But that's besides the point. Just because Emacs exists
"in the hope that it will be useful" doesn't mean one shouldn't care
about user's critical mission.