Subject: bug#70312: closed (Re: bug#70312: [PATCH v2] Avoid unnecessary escaping in url-build-query-string)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 18 Apr 2024 10:14:17 +0000

Your bug report

#70312: [PATCH] Avoid unnecessary escaping in url-build-query-string

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
70312: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70312
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#70312: [PATCH v2] Avoid unnecessary escaping in url-build-query-string
From: Eli Zaretskii <[email-masked]>
To: Dagfinn Ilmari Mannsåker <[email-masked]>
Cc: [email-masked]
Date: Thu, 18 Apr 2024 13:10:57 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Dagfinn Ilmari Mannsåker <[email-masked]>
> 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.

Subject: [PATCH] Avoid unnecessary escaping in url-build-query-string
From: Dagfinn Ilmari Mannsåker <[email-masked]>
To: [email-masked]
Date: Tue, 09 Apr 2024 15:29:00 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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

>From ca1dbe67939ac78f5db06d746cd511928a138657 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <[email-masked]>
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