>From 512cfb3b79311edbb503e4fafaa92211879899fe Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Fri, 5 Feb 2021 05:29:22 -0800 Subject: [PATCH 2/2] DROP ME: demo UTF-8 encoding of numeric addresses --- test/lisp/net/socks-tests.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/lisp/net/socks-tests.el b/test/lisp/net/socks-tests.el index d2c21094e7f..31857593dea 100644 --- a/test/lisp/net/socks-tests.el +++ b/test/lisp/net/socks-tests.el @@ -183,6 +183,29 @@ socks-tests-perform-hello-world-http-request (kill-buffer buf) (ignore url-gateway-method))) +;; XXX replace me: temporary demo showing current (flawed) behavior +;; +;; Numeric addresses with members in the Latin 1 range (127-255) get +;; encoded as their corresponding UTF-8 code points. + +(ert-deftest socks-tests-v4-bug-demo () + "Demo incorrect preparation of SOCKS4 connect command." + (let ((socks-server '("server" "127.0.0.1" 10078 4)) + (url-user-agent "Test/4-bug-demo") + (socks-tests-canned-server-patterns + `(([4 1 0 80 93 194 184 195 152 34 ?f ?o ?o 0] . [0 90 0 0 0 0 0 0]) + ;; ^~~~~~~~^~~~~~~ multi-byte ^ actually 91 err + ,socks-tests--hello-world-http-request-pattern)) + socks-nslookup-program) + (ert-info ("Make HTTP request over SOCKS4") + (cl-letf (((symbol-function 'socks-nslookup-host) + (lambda (host) + (should (equal host "example.com")) + (list 93 184 216 34))) + ((symbol-function 'user-full-name) + (lambda () "foo"))) + (socks-tests-perform-hello-world-http-request))))) + ;; Replace first pattern below with ([5 3 0 1 2] . [5 2]) to validate ;; against curl 7.71 with the following options: ;; $ curl --verbose -U foo:bar --proxy socks5h://127.0.0.1:10080 example.com -- 2.29.2