Eglot: decode unhexed file URI paths as UTF-8 (bug#79897)

'url-unhex-string' only decodes %XX sequences and returns a
unibyte string; it does not interpret the resulting octets as
UTF-8.  Its docstring says that the resulting string generally
requires decoding with an appropriate coding system.

LSP messages are UTF-8, and document URIs are transferred as URI
strings.  When recovering the file path from the URI, decode the
unhexed octets as UTF-8 instead of using them directly as an
Emacs string.  This should fix bug#79897.

Copyright-paperwork-exempt: yes

* lisp/progmodes/eglot.el (eglot-uri-to-path): Decode the
  result of 'url-unhex-string' with 'utf-8-unix'.
This commit is contained in:
duli 2026-06-22 16:20:27 +01:00 committed by João Távora
parent e940326250
commit e47bd3070a

View file

@ -1264,7 +1264,8 @@ object."
;; `file-name-handler-alist' should know how to handle them
;; (bug#58790).
(if (string= "file" (url-type url))
(let* ((unhexed (url-unhex-string (url-filename url)))
(let* ((unhexed (decode-coding-string
(url-unhex-string (url-filename url)) 'utf-8-unix))
;; Remove the leading "/" for local MS Windows-style paths.
(norm (if (and (not remote-prefix)
(eq system-type 'windows-nt)