fix(org): avoid (file-exists-p "file://") on Windows

Emacs bug#70914 handles `file://whatever` incorrectly, potentially
crashing emacs.

Fixed in emacs commit 350ae75f5c1c47a03560e43e8699781c04c9078a:
    Avoid crashes on MS-Windows due to invalid UNC file names

    * src/w32.c (parse_root): Avoid crashes due to invalid (too short)
    UNC names, such as "\\".  (Bug#70914)
This commit is contained in:
Simen Endsjø 2024-05-23 21:34:55 +02:00 committed by Henrik Lissner
parent 63605189f3
commit 587f237e93

View file

@ -502,6 +502,10 @@ relative to `org-directory', unless it is an absolute path."
(org-link-set-parameters (org-link-set-parameters
"file" :face (lambda (path) "file" :face (lambda (path)
(if (or (if (or
;; file uris is not a valid path on windows
;; ref https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-05/threads.html#00729
;; emacs <= 29 crashes for (file-exists-p "file://whatever")
(if (featurep :system 'windows) (string-prefix-p "//" path))
(file-remote-p path) (file-remote-p path)
;; filter out network shares on windows (slow) ;; filter out network shares on windows (slow)
(if (featurep :system 'windows) (string-prefix-p "\\\\" path)) (if (featurep :system 'windows) (string-prefix-p "\\\\" path))