From a8fa9c04b493324b7805dd5c6f8439b1b15a9f92 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 29 Apr 2024 10:48:09 +0200 Subject: Don't allow , in host when using Client (#1761) When using a url like http://example.com,/ URI will parse "example.com," as host. HostClient then splits this by "," into multiple addresses and will connect to example.com. HostClient splitting the address by "," is only for direct use, not for use with Client. --- client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client.go b/client.go index 1f12d4a..5cae78d 100644 --- a/client.go +++ b/client.go @@ -2,6 +2,7 @@ package fasthttp import ( "bufio" + "bytes" "crypto/tls" "errors" "fmt" @@ -477,6 +478,10 @@ func (c *Client) Do(req *Request, resp *Response) error { host := uri.Host() + if bytes.ContainsRune(host, ',') { + return fmt.Errorf("invalid host %q. Use HostClient for multiple hosts", host) + } + isTLS := false if uri.isHTTPS() { isTLS = true -- cgit v1.2.3