From 5f2877930ac69bef64b2d53e7ded4913e13c50b6 Mon Sep 17 00:00:00 2001 From: Xiyue Deng Date: Sun, 21 Jul 2024 14:54:08 -0700 Subject: [PATCH 3/6] Encode URL when requesting access * packages/oauth2/oauth2.el (oauth2-request-access): encode the whole URL to avoid having characters that breaks URL parsing. (Bug#72358) --- oauth2.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/oauth2.el b/oauth2.el index 8371e73ffb..54ca61e1cf 100644 --- a/oauth2.el +++ b/oauth2.el @@ -108,13 +108,14 @@ Return an `oauth2-token' structure." (let ((result (oauth2-make-access-request token-url - (concat - "client_id=" client-id - (when client-secret - (concat "&client_secret=" client-secret)) - "&code=" code - "&redirect_uri=" (url-hexify-string (or redirect-uri "urn:ietf:wg:oauth:2.0:oob")) - "&grant_type=authorization_code")))) + (url-encode-url + (concat + "client_id=" client-id + (when client-secret + (concat "&client_secret=" client-secret)) + "&code=" code + "&redirect_uri=" (or redirect-uri "urn:ietf:wg:oauth:2.0:oob") + "&grant_type=authorization_code"))))) (make-oauth2-token :client-id client-id :client-secret client-secret :access-token (cdr (assoc 'access_token result)) -- 2.39.2