Skip to content

net/url: clarify why @ is allowed in userinfo #73195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/net/url/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,18 @@ func validUserinfo(s string) bool {
}
switch r {
case '-', '.', '_', ':', '~', '!', '$', '&', '\'',
'(', ')', '*', '+', ',', ';', '=', '%', '@':
'(', ')', '*', '+', ',', ';', '=', '%':
continue
case '@':
// `RFC 3986 section 3.2.1` does not allow '@' in userinfo.
// It is a delimiter between userinfo and host.
// However, URLs are diverse, and in some cases,
// the userinfo may contain an '@' character,
// for example, in "http://username:p@[email protected]",
// the string "username:p@ssword" should be treated as valid userinfo.
// Ref:
// https://go.dev/issue/3439
// https://go.dev/issue/22655
continue
default:
return false
Expand Down