[net] Fix NO_PROXY does not match non-ASCII characters

17 views
Skip to first unread message

Damien Neil (Gerrit)

unread,
Mar 25, 2022, 1:00:54 PM3/25/22
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Gopher Robot, Brad Fitzpatrick, Dmitri Shuralyov, golang-co...@googlegroups.com

Damien Neil submitted this change.

View Change



6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: Brad Fitzpatrick: Looks good to me, approved; Trusted Damien Neil: Trusted; Run TryBots Gopher Robot: TryBots succeeded
net/http/httpproxy: support non-ASCII characters in NO_PROXY

Change-Id: I4b3a97a2046fcc2619535a508c9d71ffa4ca75df
GitHub-Last-Rev: 5e2316523ccaa29273e68b9c12e50f2fce36967c
GitHub-Pull-Request: golang/net#105
Reviewed-on: https://go-review.googlesource.com/c/net/+/326269
Reviewed-by: Brad Fitzpatrick <brad...@golang.org>
Trust: Brad Fitzpatrick <brad...@golang.org>
Trust: Damien Neil <dn...@google.com>
Run-TryBot: Damien Neil <dn...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
---
M http/httpproxy/proxy.go
M http/httpproxy/proxy_test.go
2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/http/httpproxy/proxy.go b/http/httpproxy/proxy.go
index d2c8c87..16994ac 100644
--- a/http/httpproxy/proxy.go
+++ b/http/httpproxy/proxy.go
@@ -267,6 +267,9 @@
matchHost = true
phost = "." + phost
}
+ if v, err := idnaASCII(phost); err == nil {
+ phost = v
+ }
c.domainMatchers = append(c.domainMatchers, domainMatch{host: phost, port: pport, matchHost: matchHost})
}
}
diff --git a/http/httpproxy/proxy_test.go b/http/httpproxy/proxy_test.go
index 2a12dad..d763732 100644
--- a/http/httpproxy/proxy_test.go
+++ b/http/httpproxy/proxy_test.go
@@ -178,7 +178,29 @@
},
req: "http://example.com/",
want: "http://proxy",
-}}
+}, {
+ cfg: httpproxy.Config{
+ NoProxy: ".示例.com",
+ HTTPProxy: "proxy",
+ },
+ req: "http://www.示例.com",
+ want: "<nil>",
+}, {
+ cfg: httpproxy.Config{
+ NoProxy: "xn--fsq092h.com",
+ HTTPProxy: "proxy",
+ },
+ req: "http://www.示例.com",
+ want: "<nil>",
+}, {
+ cfg: httpproxy.Config{
+ NoProxy: "示例.com",
+ HTTPProxy: "proxy",
+ },
+ req: "http://www.xn--fsq092h.com",
+ want: "<nil>",
+},
+}

func testProxyForURL(t *testing.T, tt proxyForURLTest) {
setHelper(t)

To view, visit change 326269. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: net
Gerrit-Branch: master
Gerrit-Change-Id: I4b3a97a2046fcc2619535a508c9d71ffa4ca75df
Gerrit-Change-Number: 326269
Gerrit-PatchSet: 8
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-CC: Shiming Zhang <zjwzs...@gmail.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages