From 4af4df18c54748eaac87be51660f3c80a415a82f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 13 Oct 2022 09:52:44 +0200 Subject: [PATCH] Fix browse-url-emacs for file: URLs on Windows * lisp/net/browse-url.el (browse-url-emacs): Fix up file:///c:/foo/bar URLs on windows (bug#58464). --- lisp/net/browse-url.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 2d528c4862c..1597f3651a5 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -1294,6 +1294,11 @@ currently selected window instead." (let ((file (url-unhex-string (url-filename parsed)))) (when-let ((coding (browse-url--file-name-coding-system))) (setq file (decode-coding-string file 'utf-8))) + ;; The local-part of file: URLs on Windows is supposed to + ;; start with an extra slash. + (when (eq system-type 'windows-nt) + (setq file (replace-regexp-in-string + "\\`/\\([a-z]:\\)" "\\1" file))) (funcall func file)) (let ((file-name-handler-alist (cons (cons url-handler-regexp 'url-file-handler) -- 2.39.5