Subject: bug#70914: 29.3; Crashes often on Windows

From: Ihor Radchenko <[email-masked]>
Date: Thu, 23 May 2024 11:51:51 +0000

Eli Zaretskii <[email-masked]> writes:

>> No. Org mode strips file: from the filename and only passes the links
>> path (link is defined as type:path)
>
> Where does that happen?  If Org does that on Windows, that's a bug:
> file:// URIs on Windows should be interpreted differently.  See
>
>   https://en.wikipedia.org/wiki/File_URI_scheme

There is no bug here. Org mode fontifies links defined by Org mode
syntax: type:path where type can be file,eww,help,etc and path is
text after type:.

So, when a package/user is supplying custom :activate-func, Org calls it
according to the convention:

`:activate-func'

  Function to run at the end of Font Lock activation.  It must
  accept four arguments:
  - the buffer position at the start of the link,
  - the buffer position at its end,
  - the path, as a string,
  - a boolean, non-nil when the link has brackets.

Here, "path" is *Org link path, according to Org mode syntax*.
So, if there is a custom function that should fontify file: links, it
knows that PATH is everything that following file:. In the discussed
case Org mode's file:// link is structured as

:type: "file"
:type-explicit-p: t
:path: "//"
:format: plain
:raw-link: "file://"
:application: nil
:search-option: nil

The :activate-func is passed the :path part, and it should know that it
is used for "file" :type. So, it has all the information necessary to
reconstruct the raw link. It can do anything it wants to with that
information.

IMHO, the bug is in file-exists-p:

file-exists-p is a function defined in fileio.c.

---

Signature
(file-exists-p FILENAME)

Documentation
Return t if file FILENAME exists (whether or not you can read it).

Return nil if FILENAME does not exist, or if there was trouble
determining whether the file exists.

---

Nothing is said in the docstring that FILENAME must follow any rules. I
read this docstring is "pass whatever string you want; if it has
problems, you will get nil as return value".

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>