From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 09 10:59:58 2024 Received: (at submit) by debbugs.gnu.org; 9 Apr 2024 14:59:58 +0000 Received: from localhost ([127.0.0.1]:51226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruCx3-0002yX-8z for submit@debbugs.gnu.org; Tue, 09 Apr 2024 10:59:58 -0400 Received: from lists.gnu.org ([2001:470:142::17]:52130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruCTW-0007VV-J5 for submit@debbugs.gnu.org; Tue, 09 Apr 2024 10:29:27 -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 1ruCTG-0006z7-1K for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 10:29:10 -0400 Received: from fhigh6-smtp.messagingengine.com ([103.168.172.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ruCTE-00012Y-05 for bug-gnu-emacs@gnu.org; Tue, 09 Apr 2024 10:29:09 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 227351140154 for ; Tue, 9 Apr 2024 10:29:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 09 Apr 2024 10:29:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm1; t=1712672944; x=1712759344; bh=6UP6w0Rzl8jbSN6GLb5ebMkMMbtu9iQh TDtLf9vkFxc=; b=hEY7NJZ1cluDV7/XBZ4fhydKy2YgCXvEt1z3uFeNIA3LR4PM lRcSihr4ZwzFFGi6IjMrJInP0rNAQ3K0/QxLWIQrJ00an49MBKV74TWtB6WZKjir BtFiLuROztBOPkvUtjFXfitXW9lBbYXDZWGBEsx32SOh2AxCJQBrsaTNLgwQMaCU RZGrjMpGCjreFx4ksYCXKFYjIerhTCl8gs1NC1+E6icI+W+9ESnbWdH50DWbaz8E HaRT0mJ9WwG7uuDLE/PAYLq7iY46T8w8UuN2H3qUJ/vY8+7kc4f3hzQb8f25nQeY MKvbpbLGA21p0XlcLhl2Zp1XpbBwIO229Vk0Hg== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1712672944; x=1712759344; bh=6UP6w0Rzl8jbSN6GLb5ebMkMMbtu9iQhTDt Lf9vkFxc=; b=Hx2HW/alkeAL5IF8Ew0xcInPhqOiInaH5X+N37NpTIOZus3FvAA xU+hejrAFy8viGUaN8BKhkpQEVL7OYDWQrBp8OgDpbe0C0RPbXJdNUBB1/OO+1d8 KVCjwYA72g95OFMKokZW20as8ytY2zcYtnTCRpVRXN4HuWnPDn/OQm/rCQH+ap3T suwesn+TneqVABxD0axXqkzrXuzyfwrOfoW3O0o8mdSPGwcWm/avTndU+NzSPO+B 90agjm/JHLPwI39V7mw72Q8drG4QRn+T6I4f8dLtxN5ZSePXuR3MMq/++uFxYinY rOQRNXIBmafJiKVkQ+wHwO6E81qwQioJioA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehvddgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkfgggtgesmhdtreertd erjeenucfhrhhomhepffgrghhfihhnnhcukfhlmhgrrhhiucforghnnhhsnohkvghruceo ihhlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepieeiveetvd euveevkeefueejieekgfdvtdetffekgeejtedvjeetheehueeliedvnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrg hrihdrohhrgh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 9 Apr 2024 10:29:03 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: bug-gnu-emacs@gnu.org Subject: [PATCH] Avoid unnecessary escaping in url-build-query-string Date: Tue, 09 Apr 2024 15:29:00 +0100 Message-ID: <8734ruk3tf.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=103.168.172.157; envelope-from=ilmari@ilmari.org; helo=fhigh6-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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 09 Apr 2024 10:59:53 -0400 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 Hi, While writing a custom URL function for git-link.el I noticed that url-build-query-string unnecessarily escapes slashes in query parameter values. Here's a patch that fixes that by passing url-query-allowed-chars to the url-hexify-string call. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Avoid-unnecessary-escaping-in-url-build-query-string.patch >From ca1dbe67939ac78f5db06d746cd511928a138657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 9 Apr 2024 15:02:45 +0100 Subject: [PATCH] Avoid unnecessary escaping in url-build-query-string * lisp/url/url-util.el (url-build-query-string): Pass url-query-allowed-chars to url-hexify-string to avoid unnecessarily escaping characters that don't need to be escaped in a query string. --- lisp/url/url-util.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index 5f45b98c7a5..4fc0efcdf62 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el @@ -268,7 +268,8 @@ instead of just \"key\" as in the example above." (lambda (key-vals) (let ((escaped (mapcar (lambda (sym) - (url-hexify-string (format "%s" sym))) key-vals))) + (url-hexify-string (format "%s" sym) url-query-allowed-chars)) + key-vals))) (mapconcat (lambda (val) (let ((vprint (format "%s" val)) (eprint (format "%s" (car escaped)))) -- 2.39.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 09 12:41:31 2024 Received: (at 70312) by debbugs.gnu.org; 9 Apr 2024 16:41:31 +0000 Received: from localhost ([127.0.0.1]:51306 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruEXL-0000Wq-0e for submit@debbugs.gnu.org; Tue, 09 Apr 2024 12:41:31 -0400 Received: from fout4-smtp.messagingengine.com ([103.168.172.147]:38381) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ruEXE-0000VF-Di for 70312@debbugs.gnu.org; Tue, 09 Apr 2024 12:41:28 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id 95D12138018C for <70312@debbugs.gnu.org>; Tue, 9 Apr 2024 12:41:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 09 Apr 2024 12:41:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm1; t=1712680870; x=1712767270; bh=IEmemT7t1oF0Aet+xPBrkGB70p3ZAaIb V8RP76+Wl24=; b=My5yiv+luiJ2ruXVVn6/g4fnt1pZNuNRP2pU8jD7K+Hi0FtA Gac0cZFw0wIUBNy7mLTPtNFTSX90yBueBhalOU590pBvXh6Q3b0B2SFbDMyREop5 Ox+/8JjXnfQ08uF0Re/PawO2uX3ZrBUSaGN5GWPnEKnebUY+Xg/oyiJtt9uwXHph NPxFjQcQnPaV8uQhtl0wETphCOqCjGm5YszC1q6KZBzMoXU6i5+GJWs80YgUvtwT lRkPf6AQYSaYcwEo48Gw3MvdVVOpMT42Xom0xZdIdKryVfcEa0j7pkKJwgy5NGXy 6bM05/McUPD4xfEqVwBt8dy3cR+RAkWfE3w40A== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1712680870; x=1712767270; bh=IEmemT7t1oF0Aet+xPBrkGB70p3ZAaIbV8R P76+Wl24=; b=Hf1gtuUz+BSJvf+qlckkL5G5p1RNf6fZ5QRwkuhNmlEpOidGHmr n++GflO0DbjcBaSQnN0L+jVrg3burZWSoVr0ctRdLJDvUA+tjrtoI049gnXHxtz+ g8ipczUhm5FEBqrPxdgb5cC7YlNTpXcTsUZlIbE50a5w0NJaM1ZrHvZ5NY1CBOQG xs/1aYLNbWopIKQ92T8PYTFBpEEGfRO+t180ycQbjiknokwHJc5Ki4CgrniuLTnL A7oS1/QuqbtPKniCvoraF6RKk8d2LLipVpTGgCBQ80oOq3k/DMPRe1az4xUxrpYS FDMo1FI9OL1Ic0TClKiVnScpy26WM/acDew== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehfedguddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkfgggtgesmhdtreertd erjeenucfhrhhomhepffgrghhfihhnnhcukfhlmhgrrhhiucforghnnhhsnohkvghruceo ihhlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepieeiveetvd euveevkeefueejieekgfdvtdetffekgeejtedvjeetheehueeliedvnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrg hrihdrohhrgh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <70312@debbugs.gnu.org>; Tue, 9 Apr 2024 12:41:09 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: 70312@debbugs.gnu.org Subject: [PATCH v2] Avoid unnecessary escaping in url-build-query-string Date: Tue, 09 Apr 2024 17:41:07 +0100 Message-ID: <87zfu2ij4s.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 70312 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: -1.7 (-) --=-=-= Content-Type: text/plain Hi again, I realised I'd forgotten to add tests, and that made me realise that url-query-allowed-chars is not correct for this, since that also contains '=', '&', and ';'. So here's an updated patch, which creates a new url-query-key-value-allowed-chars constant, which is url-query-allowed-chars minus the aforementioned three chars, and adds tests covering that, for both keys and values. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Avoid-unnecessary-escaping-in-url-build-query-str.patch >From 89db0a1226d8d7cca1846e9c737d4a67c971ec75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 9 Apr 2024 15:02:45 +0100 Subject: [PATCH v2] Avoid unnecessary escaping in url-build-query-string * lisp/url/url-util.el (url-build-query-string): Create a new url-query-key-value-allowed-chars constant and pass that to url-hexify-string to avoid unnecessarily escaping characters that don't need to be escaped in query string keys and values. * test/lisp/url/url-util-tests.el (url-util-tests): Add test cases. --- lisp/url/url-util.el | 12 +++++++++++- test/lisp/url/url-util-tests.el | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index 5f45b98c7a5..f063efe18a6 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el @@ -268,7 +268,8 @@ url-build-query-string (lambda (key-vals) (let ((escaped (mapcar (lambda (sym) - (url-hexify-string (format "%s" sym))) key-vals))) + (url-hexify-string (format "%s" sym) url-query-key-value-allowed-chars)) + key-vals))) (mapconcat (lambda (val) (let ((vprint (format "%s" val)) (eprint (format "%s" (car escaped)))) @@ -410,6 +411,15 @@ url-query-allowed-chars "Allowed-character byte mask for the query segment of a URI. These characters are specified in RFC 3986, Appendix A.") +(defconst url-query-key-value-allowed-chars + (let ((vec (copy-sequence url-query-allowed-chars))) + (aset vec ?= nil) + (aset vec ?& nil) + (aset vec ?\; nil) + vec) + "Allowed-charcter byte mask for keys and values in the query segment of a URI. +url-query-allowed-chars minus '=', '&', and ';'.") + ;;;###autoload (defun url-encode-url (url) "Return a properly URI-encoded version of URL. diff --git a/test/lisp/url/url-util-tests.el b/test/lisp/url/url-util-tests.el index 133aa0ffd88..c6246d69a2a 100644 --- a/test/lisp/url/url-util-tests.el +++ b/test/lisp/url/url-util-tests.el @@ -32,7 +32,11 @@ url-util-tests ("key1=val1;key2=val2;key3=val1;key3=val2;key4;key5" ((key1 "val1") (key2 val2) (key3 val1 val2) ("key4") (key5 "")) t) ("key1=val1;key2=val2;key3=val1;key3=val2;key4=;key5=" - ((key1 val1) (key2 val2) ("key3" val1 val2) (key4) (key5 "")) t t))) + ((key1 val1) (key2 val2) ("key3" val1 val2) (key4) (key5 "")) t t) + ("key1=val/slash;key2=val%3Bsemi;key3=val%26amp;key4=val%3Deq" + ((key1 "val/slash") (key2 "val;semi") (key3 "val&") (key4 "val=eq")) t) + ("key%3Deq=val1;key%3Bsemi=val2;key%26amp=val3" + (("key=eq" val1) ("key;semi" val2) ("key&" val3)) t))) test) (while tests (setq test (car tests) -- 2.39.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 18 06:13:33 2024 Received: (at 70312-done) by debbugs.gnu.org; 18 Apr 2024 10:13:35 +0000 Received: from localhost ([127.0.0.1]:51496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxOli-00076P-B0 for submit@debbugs.gnu.org; Thu, 18 Apr 2024 06:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxOje-0006sM-88 for 70312-done@debbugs.gnu.org; Thu, 18 Apr 2024 06:11:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxOjL-0004lM-3U; Thu, 18 Apr 2024 06:10:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=YQscop40ymfv2VhlutMtiFknj9uVuX8feoShLyJ/kGo=; b=db3PMBJ3Hy4G1b2k3qW9 ru1O5uvQNbC+2peZ5y1ZGdeiNaWT1M3zAwP5WYfUMP5kSiXd8ifccknMu2oTJJ6Iwu77Hlo2NEC6o paLzCzHyRe5DrN2dHNpbQb7tk2p30DvJ4H43jky83l7jv21MidMGkcIkL7Z7ELnlreYPUMzpTdUat pjI7/oIGdrQaZDJzU1bczrRR7CiSLi2Z7xxDgDmE/EFU2pN/keORZKF+DruoESniCd0sBxUjn44lj GXWFX/3wKPGcCGk+U3C4ohdFXfxOuyoSoXbSuaWuBUktoFSIXVzN34GkN1OhuUeScCEt/mc+Znk6E w4MPP6rLw0WcUQ==; Date: Thu, 18 Apr 2024 13:10:57 +0300 Message-Id: <86zftrdlqm.fsf@gnu.org> From: Eli Zaretskii To: Dagfinn Ilmari =?iso-8859-1?Q?Manns=E5ker?= In-Reply-To: <87zfu2ij4s.fsf@wibble.ilmari.org> (message from Dagfinn Ilmari =?iso-8859-1?Q?Manns=E5ker?= on Tue, 09 Apr 2024 17:41:07 +0100) Subject: Re: bug#70312: [PATCH v2] Avoid unnecessary escaping in url-build-query-string References: <8734ruk3tf.fsf@wibble.ilmari.org> <87zfu2ij4s.fsf@wibble.ilmari.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70312-done Cc: 70312-done@debbugs.gnu.org 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: -3.3 (---) > From: Dagfinn Ilmari Mannsåker > Date: Tue, 09 Apr 2024 17:41:07 +0100 > > I realised I'd forgotten to add tests, and that made me realise that > url-query-allowed-chars is not correct for this, since that also > contains '=', '&', and ';'. So here's an updated patch, which creates a > new url-query-key-value-allowed-chars constant, which is > url-query-allowed-chars minus the aforementioned three chars, and adds > tests covering that, for both keys and values. Thanks, I installed this on the master branch, and I'm closing this bug. With this contribution, you have exhausted the maximum amount of code changes we can accept from you without a copyright assignment. Would you like to start your assignment paperwork now, so that we could accept your future contributions without limitations? If yes, I will send you a form to fill and the instructions to go with it. From unknown Sun Jun 22 00:27:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 16 May 2024 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun May 19 07:14:09 2024 Received: (at control) by debbugs.gnu.org; 19 May 2024 11:14:10 +0000 Received: from localhost ([127.0.0.1]:35957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eUT-0004Kv-LH for submit@debbugs.gnu.org; Sun, 19 May 2024 07:14:09 -0400 Received: from mout02.posteo.de ([185.67.36.66]:55937) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eUR-0004Kf-Sb for control@debbugs.gnu.org; Sun, 19 May 2024 07:14:08 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 75B0D240103 for ; Sun, 19 May 2024 13:13:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716117237; bh=Y6J1LDpGZ5+ugF8qoUE+XGKkLvpHMVuHtd6S7H5nc3c=; h=Date:Message-Id:To:From:Subject:From; b=sJSnT7p6Fm9qzktx2uTsfRm9TlOtf7Xig0A8BsdFJdBHOBo5GZXxYZj3Q0lFFvDq5 YLKgpqtTLwt/2IB8iyYJC7MpbrChBAvwzkdAceRNk8D7n0f1ixXMatxRxnSCrJ2PlT 6PdutPgZEl7JlZkltKibR8ZX6l3d/kXqQJyWuQEw30HxvsMdKdwwySmkI0E0kzXvvw qa85494Ox8H3qVyr00CjXNNaWN83gkXjqxvy9qqX0A53NemUJLTvjVhcQoda/Rq8jX sZmQBEb38L5DDmVLpfjPZro65sptuioyDRDT5h9OOhZNpSbAwFFciY5V2vtBHi/w6F e+JXaMmuQxv0A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VhykY10VNz6tyj for ; Sun, 19 May 2024 13:13:57 +0200 (CEST) Date: Sun, 19 May 2024 11:13:56 +0000 Message-Id: <87ikzauk97.fsf@posteo.net> To: control@debbugs.gnu.org From: Philip Kaludercic Subject: control message for bug #70312 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control 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: -3.3 (---) unarchive 70312 quit From debbugs-submit-bounces@debbugs.gnu.org Sun May 19 07:19:01 2024 Received: (at 70312) by debbugs.gnu.org; 19 May 2024 11:19:01 +0000 Received: from localhost ([127.0.0.1]:35968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eZA-0004P5-N6 for submit@debbugs.gnu.org; Sun, 19 May 2024 07:19:01 -0400 Received: from mout01.posteo.de ([185.67.36.65]:53889) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eZ8-0004Oz-5e for 70312@debbugs.gnu.org; Sun, 19 May 2024 07:18:59 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id F094F240027 for <70312@debbugs.gnu.org>; Sun, 19 May 2024 13:18:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716117528; bh=tWiNVzxFT9sX0uFlQbENM9HIJIiXomFzE55YS2tPp+s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=PMqOcm4GXSS7v4QDz7XAXlcLZ65kUrmlMh/lcCGyAcsXebBYTVk/PeGIVZVwXtsjT bKz0ZsfbcUMaWR/JZjxganckPhii0fNTYv+lYAWnAj9UGW56E6XSEBylzNUa4atHDY HNf1eXgfcUO7zZTc1/kZ+ZRYZK3enyno/u7lLqohqpE6ms/kh7jD7zVJeObk1p8HRD kphXdQ9YVb0SGyDPF2cRqqBBq3+5COmx61A9nhhXrslsMIja+jAcAdvJ6qU9E/qrhw sWH8QSddRlL4MDc+sp+D6uGSpbCGpgcxQSb/DoiN+I+XSZqCMiA4CPlvJg3YHdzhiX wbjxdS3QjVMAg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Vhyr73kZFz9rxD; Sun, 19 May 2024 13:18:47 +0200 (CEST) From: Philip Kaludercic To: Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= Subject: Re: bug#70312: [PATCH v2] Avoid unnecessary escaping in url-build-query-string In-Reply-To: <87zfu2ij4s.fsf@wibble.ilmari.org> ("Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker=22's?= message of "Tue, 09 Apr 2024 17:41:07 +0100") References: <8734ruk3tf.fsf@wibble.ilmari.org> <87zfu2ij4s.fsf@wibble.ilmari.org> X-Hashcash: 1:20:240519:70312@debbugs.gnu.org::DYlLrWY9wnUHdTvq:9E9 X-Hashcash: 1:20:240519:ilmari@ilmari.org::FlM6eWcHE+IntaYr:3Nh2 Date: Sun, 19 May 2024 11:18:47 +0000 Message-ID: <87bk52uk14.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70312 Cc: 70312@debbugs.gnu.org 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: -3.3 (---) Dagfinn Ilmari Manns=C3=A5ker writes: > Hi again, > > I realised I'd forgotten to add tests, and that made me realise that > url-query-allowed-chars is not correct for this, since that also > contains '=3D', '&', and ';'. So here's an updated patch, which creates a > new url-query-key-value-allowed-chars constant, which is > url-query-allowed-chars minus the aforementioned three chars, and adds > tests covering that, for both keys and values. This patch breaks a script I have that authenticates via HTTP. Apparently it doesn't escape enough now: (url-build-query-string '((var "\"$%&')+:;<>?@]^{|}"))) "var=3D%22$%%26')+:%3B%3C%3E?@%5D%5E%7B%7C%7D" whereas it used to be: (url-build-query-string '((var "\"$%&')+:;<>?@]^{|}"))) "var=3D%22%24%25%26%27%29%2B%3A%3B%3C%3E%3F%40%5D%5E%7B%7C%7D" If it is true, that it just unnecessarily escapes too much (and this is not a problem), then I'd suggest reverting the patch as the easiest solution to avoid breakage in the long term. > > - ilmari > >>>From 89db0a1226d8d7cca1846e9c737d4a67c971ec75 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Dagfinn=3D20Ilmari=3D20Manns=3DC3=3DA5ker?=3D > Date: Tue, 9 Apr 2024 15:02:45 +0100 > Subject: [PATCH v2] Avoid unnecessary escaping in url-build-query-string > > * lisp/url/url-util.el (url-build-query-string): > Create a new url-query-key-value-allowed-chars constant and pass that to > url-hexify-string to avoid unnecessarily escaping characters that don't > need to be escaped in query string keys and values. > * test/lisp/url/url-util-tests.el (url-util-tests): > Add test cases. > --- > lisp/url/url-util.el | 12 +++++++++++- > test/lisp/url/url-util-tests.el | 6 +++++- > 2 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el > index 5f45b98c7a5..f063efe18a6 100644 > --- a/lisp/url/url-util.el > +++ b/lisp/url/url-util.el > @@ -268,7 +268,8 @@ url-build-query-string > (lambda (key-vals) > (let ((escaped > (mapcar (lambda (sym) > - (url-hexify-string (format "%s" sym))) key-vals))) > + (url-hexify-string (format "%s" sym) url-query-key= -value-allowed-chars)) > + key-vals))) > (mapconcat (lambda (val) > (let ((vprint (format "%s" val)) > (eprint (format "%s" (car escaped)))) > @@ -410,6 +411,15 @@ url-query-allowed-chars > "Allowed-character byte mask for the query segment of a URI. > These characters are specified in RFC 3986, Appendix A.") >=20=20 > +(defconst url-query-key-value-allowed-chars > + (let ((vec (copy-sequence url-query-allowed-chars))) > + (aset vec ?=3D nil) > + (aset vec ?& nil) > + (aset vec ?\; nil) > + vec) > + "Allowed-charcter byte mask for keys and values in the query segment o= f a URI. > +url-query-allowed-chars minus '=3D', '&', and ';'.") > + > ;;;###autoload > (defun url-encode-url (url) > "Return a properly URI-encoded version of URL. > diff --git a/test/lisp/url/url-util-tests.el b/test/lisp/url/url-util-tes= ts.el > index 133aa0ffd88..c6246d69a2a 100644 > --- a/test/lisp/url/url-util-tests.el > +++ b/test/lisp/url/url-util-tests.el > @@ -32,7 +32,11 @@ url-util-tests > ("key1=3Dval1;key2=3Dval2;key3=3Dval1;key3=3Dval2;key4;key5" > ((key1 "val1") (key2 val2) (key3 val1 val2) ("key4") (key5 "= ")) t) > ("key1=3Dval1;key2=3Dval2;key3=3Dval1;key3=3Dval2;key4=3D;key= 5=3D" > - ((key1 val1) (key2 val2) ("key3" val1 val2) (key4) (key5 "")= ) t t))) > + ((key1 val1) (key2 val2) ("key3" val1 val2) (key4) (key5 "")= ) t t) > + ("key1=3Dval/slash;key2=3Dval%3Bsemi;key3=3Dval%26amp;key4=3D= val%3Deq" > + ((key1 "val/slash") (key2 "val;semi") (key3 "val&") (key4= "val=3Deq")) t) > + ("key%3Deq=3Dval1;key%3Bsemi=3Dval2;key%26amp=3Dval3" > + (("key=3Deq" val1) ("key;semi" val2) ("key&" val3)) t))) > test) > (while tests > (setq test (car tests) --=20 Philip Kaludercic on icterid From unknown Sun Jun 22 00:27:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 16 Jun 2024 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator