Subject: bug#54921: eww/url mishandles IDN over proxy

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 15 Apr 2022 10:35:02 +0200

Andreas Schwab <[email-masked]> writes:

> The proxy just receives the full URL in the GET request.  Something like
> this, but puny-encode-domain must only be called with the domain name.

Right.  Does the following untested patch work?

diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 96a4742956..b5bcd123c7 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -332,7 +332,10 @@ url-http-create-request
               (if (and using-proxy
                        ;; Bug#35969.
                        (not (equal "https" (url-type url-http-target-url))))
-                  (url-recreate-url url-http-target-url) real-fname))
+                  (let ((url (copy-sequence url-http-target-url)))
+                    (setf (url-host url) (puny-encode-domain (url-host url)))
+                    (url-recreate-url url))
+                real-fname))
              " HTTP/" url-http-version "\r\n"
              ;; Version of MIME we speak
              "MIME-Version: 1.0\r\n"

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no