You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I review source code about the String() in net/url/url.go , It will return unexpect url when the username is null string.
s := escape(u.username, encodeUserPassword)
if u.passwordSet {
s += ":" + escape(u.password, encodeUserPassword)
}
What did you expect to see?
I expect that Userinfo.String() function could return correct string when username is null string.
// String returns the encoded userinfo information in the standard form
// of "username[:password]".
func (u *Userinfo) String() string {
if u == nil {
return ""
}
s := escape(u.username, encodeUserPassword)
if u.passwordSet {
**s += ":" + escape(u.password, encodeUserPassword)**
}
return s
}
What did you see instead?
The text was updated successfully, but these errors were encountered:
guanyux
changed the title
affected/package: net/url
affected/package: net/url userinfo.String() return unexpect url when the username is null string
Mar 8, 2022
guanyux
changed the title
affected/package: net/url userinfo.String() return unexpect url when the username is null string
userinfo.String() return unexpect url when the username is null string affected/package: net/url
Mar 8, 2022
mengzhuo
changed the title
userinfo.String() return unexpect url when the username is null string affected/package: net/url
net/url: userinfo.String() return unexpect url when the username is null string
Mar 8, 2022
From RFC 3986, and the documentation the username is required while the password is optional. The colon separates the empty username from the password.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I want to access github api with token like this:
unexpectedly I found that there is an extra colon in the url like this:
"https://:ghp_snNcRtoWc6Uy5Vxxxxxxx@github.com/tf-xxx/tfxxx.git/"
So I review source code about the String() in net/url/url.go , It will return unexpect url when the username is null string.
What did you expect to see?
I expect that Userinfo.String() function could return correct string when username is null string.
What did you see instead?
The text was updated successfully, but these errors were encountered: