aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Allen2025-08-30 11:19:05 +0100
committerJoão Távora2025-08-30 11:19:19 +0100
commit4ab16d701ecda72d8ed74cf0a5f0f63dfeeb087d (patch)
treea330e3f445238c51626257074a1c0ced3507553d
parent8d301906e1f53b366316754d1f3ff2ad7f0f673c (diff)
downloademacs-4ab16d701ecda72d8ed74cf0a5f0f63dfeeb087d.tar.gz
emacs-4ab16d701ecda72d8ed74cf0a5f0f63dfeeb087d.zip
Eglot: escape literal % characters in URIs
Escape literal % characters in Eglot URIs Otherwise, a literal % in a file-name will be interpreted (by the language server) as if it were a part of a percent-encoded sequence. See Bug#78984 for context on why `url-path-allowed-chars' cannot be changed to escape literal % characters. * lisp/progmodes/eglot.el (eglot--uri-path-allowed-chars): Escape %, remove the redundant variable definition. * test/lisp/progmodes/eglot-tests.el (eglot-test-path-to-uri-escape): test it.
-rw-r--r--lisp/progmodes/eglot.el7
-rw-r--r--test/lisp/progmodes/eglot-tests.el4
2 files changed, 5 insertions, 6 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 29e6c269fdf..ee76d2fd5e4 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -675,6 +675,7 @@ This can be useful when using docker to run a language server.")
675(defconst eglot--uri-path-allowed-chars 675(defconst eglot--uri-path-allowed-chars
676 (let ((vec (copy-sequence url-path-allowed-chars))) 676 (let ((vec (copy-sequence url-path-allowed-chars)))
677 (aset vec ?: nil) ;; see github#639 677 (aset vec ?: nil) ;; see github#639
678 (aset vec ?% nil) ;; see bug#78984
678 vec) 679 vec)
679 "Like `url-path-allowed-chars' but more restrictive.") 680 "Like `url-path-allowed-chars' but more restrictive.")
680 681
@@ -2008,12 +2009,6 @@ If optional MARKER, return a marker instead"
2008 2009
2009 2010
2010;;; More helpers 2011;;; More helpers
2011(defconst eglot--uri-path-allowed-chars
2012 (let ((vec (copy-sequence url-path-allowed-chars)))
2013 (aset vec ?: nil) ;; see github#639
2014 vec)
2015 "Like `url-path-allowed-chars' but more restrictive.")
2016
2017(defun eglot--snippet-expansion-fn () 2012(defun eglot--snippet-expansion-fn ()
2018 "Compute a function to expand snippets. 2013 "Compute a function to expand snippets.
2019Doubles as an indicator of snippet support." 2014Doubles as an indicator of snippet support."
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el
index 7fd4f0f0491..b01b7d269ec 100644
--- a/test/lisp/progmodes/eglot-tests.el
+++ b/test/lisp/progmodes/eglot-tests.el
@@ -1469,6 +1469,10 @@ GUESSED-MAJOR-MODES-SYM are bound to the useful return values of
1469 (should (string-suffix-p "c%3A/Users/Foo/bar.lisp" 1469 (should (string-suffix-p "c%3A/Users/Foo/bar.lisp"
1470 (eglot-path-to-uri "c:/Users/Foo/bar.lisp")))) 1470 (eglot-path-to-uri "c:/Users/Foo/bar.lisp"))))
1471 1471
1472(ert-deftest eglot-test-path-to-uri-escape ()
1473 (should (equal "file:///path/with%20%25%20funny%20%3F%20characters"
1474 (eglot-path-to-uri "/path/with % funny ? characters"))))
1475
1472(ert-deftest eglot-test-same-server-multi-mode () 1476(ert-deftest eglot-test-same-server-multi-mode ()
1473 "Check single LSP instance manages multiple modes in same project." 1477 "Check single LSP instance manages multiple modes in same project."
1474 (skip-unless (executable-find "clangd")) 1478 (skip-unless (executable-find "clangd"))