Skip to content

Commit 1551221

Browse files
committed
Reject URIs containing user information
WebSocket URIs do not contain user information per section 3 of RFC 6455. Fixes gorilla#65
1 parent 6fd0f86 commit 1551221

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

client.go

+5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ func parseURL(s string) (*url.URL, error) {
130130
u.Opaque = s[i:]
131131
}
132132

133+
if strings.Contains(u.Host, "@") {
134+
// WebSocket URIs do not contain user information.
135+
return nil, errMalformedURL
136+
}
137+
133138
return &u, nil
134139
}
135140

client_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var parseURLTests = []struct {
2020
{"wss://example.com/", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/"}},
2121
{"wss://example.com/a/b", &url.URL{Scheme: "wss", Host: "example.com", Opaque: "/a/b"}},
2222
{"ss://example.com/a/b", nil},
23+
{"ws://[email protected]/", nil},
2324
}
2425

2526
func TestParseURL(t *testing.T) {

0 commit comments

Comments
 (0)