From unknown Fri Aug 15 18:45:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79185: [PATCH] Escape literal % characters in Eglot URIs Resent-From: Steven Allen Original-Sender: "Debbugs-submit" Resent-CC: joaotavora@gmail.com, joaotavora@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 18:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 79185 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 79185@debbugs.gnu.org Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Received: via spool by submit@debbugs.gnu.org id=B.175450439116912 (code B ref -1); Wed, 06 Aug 2025 18:20:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Aug 2025 18:19:51 +0000 Received: from localhost ([127.0.0.1]:60055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujiju-0004Oh-VQ for submit@debbugs.gnu.org; Wed, 06 Aug 2025 14:19:51 -0400 Received: from lists.gnu.org ([2001:470:142::17]:42180) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujijs-0004OU-Lp for submit@debbugs.gnu.org; Wed, 06 Aug 2025 14:19:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujijm-00060Y-LQ for bug-gnu-emacs@gnu.org; Wed, 06 Aug 2025 14:19:42 -0400 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujijh-00068l-SP for bug-gnu-emacs@gnu.org; Wed, 06 Aug 2025 14:19:41 -0400 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id C42987A019F for ; Wed, 6 Aug 2025 14:19:34 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Wed, 06 Aug 2025 14:19:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm2; t=1754504374; x=1754590774; bh=0oMmtYPFcMqDHBrtec+KG5QmdTjotgvV Nhsdx/vMJYE=; b=Rt0Aq6V9Z9xjiX3IE8VwenoxdzteUeN9YlyyNYCPQlueB6mo 3wXb7nJtCrp9HFh3zwFCfYUxA+YFRp/0TZlUk4ehdFHYszbX16L0V/EUn6vcRG8Y taMgQbX+k10Kzipe5z9mr5d/vqBfoL4zCHF+oMvpIis5oG7iXwxW4s2KanUIChao q9XdA8FoYJGXCPX4R/GBCr13R8R8FC8gUCYIjLUPegZkDuIMgF6byjaCPGXF0/f3 Lqd0URH7jPRf+Toz1YIvl04vzDnu3foQg0JHelEszuVmpeKNQouVAJKIgarH34pQ DMtiiZIOOSNQMydY77U5h6EbvcK+JwEgOXPdYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1754504374; x= 1754590774; bh=0oMmtYPFcMqDHBrtec+KG5QmdTjotgvVNhsdx/vMJYE=; b=I WDDS5afIzuKl1zLWhs22ydzdzf+NfywU4qc45dLHUEDpXFNc+zTFjnprtWLEZ/r3 XFR6GtFfDazNXK5ZWUAJFV88Y4Y3j9F9EV2fY3tEOYhP7dzLqjafHLbhxPNqIz5v 9q74VaJqOhi/1vS+4+lEZi+XVPH0EfwbeFaLIVxVRiXceV1+8TLnstbsmovCWIuH fbQs3TyAT0seD36mA/NjNZDXI1m16UYk6vFAOZM/qJ7qdeu/JaJiPuIa02k6A3W/ jEUFuD0M5KUh7smNKWQLjKLa4i0Ku4Pi5rWQiXUxvMJWR9/yRVgUpdu9YRN5+iie jLv50NcmxIrIRia96S0Bw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduudekjeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehmtderredttddtne cuhfhrohhmpefuthgvvhgvnhcutehllhgvnhcuoehsthgvvhgvnhesshhtvggsrghlihgv nhdrtghomheqnecuggftrfgrthhtvghrnhepkefffffgveethedtieffleffgeekvdeiie egheeftdetjeekfefhvedttdekfeffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhmpdhnsg gprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsuhhgqdhg nhhuqdgvmhgrtghssehgnhhurdhorhhg X-ME-Proxy: Feedback-ID: ie8a146a7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 6 Aug 2025 14:19:33 -0400 (EDT) From: Steven Allen Date: Wed, 06 Aug 2025 11:19:29 -0700 Message-ID: <874iuk9utq.fsf@stebalien.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=202.12.124.153; envelope-from=steven@stebalien.com; helo=fhigh-b2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) --=-=-= Content-Type: text/plain Tags: patch Without this, 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. In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, cairo version 1.18.4) of 2025-08-06 built on Laptop Repository revision: ca38912a544c73f120fa1ad15233fb8cc9224a44 Repository branch: makepkg Windowing system distributor 'The X.Org Foundation', version 11.0.12101018 System Description: Arch Linux Configured using: 'configure 'CPPFLAGS=-I/run/user/1000/build/emacs-git/src/mps-git/build/include ' 'LDFLAGS=-L/run/user/1000/build/emacs-git/src/mps-git/build/lib -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto' --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games --with-modules --without-m17n-flt --without-selinux --without-pop --without-gconf --disable-gc-mark-trace --with-mps=yes --enable-link-time-optimization --with-native-compilation=yes --with-xinput2 --with-x-toolkit=no --without-toolkit-scroll-bars --without-xaw3d --without-gsettings --with-cairo-xcb --without-xft --with-sound=no --with-tree-sitter --without-gpm --without-compress-install '--program-transform-name=s/\([ec]tags\)/\1.emacs/' 'CFLAGS=-march=native -mtune=native -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fomit-frame-pointer -fno-math-errno -fno-trapping-math -fno-math-errno -fno-trapping-math -flto=auto'' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Escape-literal-characters-in-Eglot-URIs.patch >From 9ff0c35ab2a69b542f0dfeec76eefa499729db3d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 26 Jul 2025 13:14:19 -0700 Subject: [PATCH] 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. --- lisp/progmodes/eglot.el | 7 +------ test/lisp/progmodes/eglot-tests.el | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 4a7c525003c..53976a81e11 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -675,6 +675,7 @@ eglot--accepted-formats (defconst eglot--uri-path-allowed-chars (let ((vec (copy-sequence url-path-allowed-chars))) (aset vec ?: nil) ;; see github#639 + (aset vec ?% nil) ;; see bug#78984 vec) "Like `url-path-allowed-chars' but more restrictive.") @@ -2008,12 +2009,6 @@ eglot--lsp-position-to-point ;;; More helpers -(defconst eglot--uri-path-allowed-chars - (let ((vec (copy-sequence url-path-allowed-chars))) - (aset vec ?: nil) ;; see github#639 - vec) - "Like `url-path-allowed-chars' but more restrictive.") - (defun eglot--snippet-expansion-fn () "Compute a function to expand snippets. Doubles as an indicator of snippet support." diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index 2b98da4134b..269de422690 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el @@ -1468,6 +1468,10 @@ eglot-test-path-to-uri-windows (should (string-suffix-p "c%3A/Users/Foo/bar.lisp" (eglot-path-to-uri "c:/Users/Foo/bar.lisp")))) +(ert-deftest eglot-test-path-to-uri-escape () + (should (equal "file:///path/with%20%25%20funny%20%3F%20characters" + (eglot-path-to-uri "/path/with % funny ? characters")))) + (ert-deftest eglot-test-same-server-multi-mode () "Check single LSP instance manages multiple modes in same project." (skip-unless (executable-find "clangd")) -- 2.50.1 --=-=-=--