From ff91ba70cd24e7469c7c171234363c82b1566cd6 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 6 Mar 2021 21:18:48 +0100 Subject: [PATCH] Convert colon to hex in uri MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit On windows, in the path portion of the URI, ':' must be hexified to '%3A'. In the URL scheme, the ':' stays. * eglot.el (eglot--uri-path-allowed-chars): define what characters are allowed in path portion of URI. * eglot.el (eglot--path-to-uri): ensure colon in 'file://' stays, but and others are hexified. Co-authored-by: João Távora GitHub-reference: fix https://github.com/joaotavora/eglot/issues/638 --- lisp/progmodes/eglot.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e0896c85017..d4300e186be 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1190,13 +1190,19 @@ If optional MARKER, return a marker instead" (funcall eglot-move-to-column-function col))) (if marker (copy-marker (point-marker)) (point))))) +(defconst eglot--uri-path-allowed-chars + (let ((vec (copy-sequence url-path-allowed-chars))) + (aset vec ?: nil) ;; see github#639 + vec) + "Like `url-path-allows-chars' but more restrictive.") + (defun eglot--path-to-uri (path) "URIfy PATH." - (url-hexify-string - (concat "file://" (if (eq system-type 'windows-nt) "/") + (concat "file://" (if (eq system-type 'windows-nt) "/") + (url-hexify-string ;; Again watch out for trampy paths. - (directory-file-name (file-local-name (file-truename path)))) - url-path-allowed-chars)) + (directory-file-name (file-local-name (file-truename path))) + eglot--uri-path-allowed-chars))) (defun eglot--uri-to-path (uri) "Convert URI to file path, helped by `eglot--current-server'." -- 2.39.2