diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-06-25 16:20:03 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-06-25 16:20:03 +0000 |
commit | 08a680a8879ce9da16d808644730f7cfacaf667f (patch) | |
tree | 5dfe28c3f573ae57b971ed4d9a1c99a76f0a70c4 /libgo/go/net/url | |
parent | 72de8622ae2d5aaeb58173f454aed87640a989b5 (diff) | |
download | gcc-08a680a8879ce9da16d808644730f7cfacaf667f.zip gcc-08a680a8879ce9da16d808644730f7cfacaf667f.tar.gz gcc-08a680a8879ce9da16d808644730f7cfacaf667f.tar.bz2 |
libgo: Update to Go 1.0.2 release.
From-SVN: r188943
Diffstat (limited to 'libgo/go/net/url')
-rw-r--r-- | libgo/go/net/url/url.go | 5 | ||||
-rw-r--r-- | libgo/go/net/url/url_test.go | 31 |
2 files changed, 34 insertions, 2 deletions
diff --git a/libgo/go/net/url/url.go b/libgo/go/net/url/url.go index b6e79ad..17bf0d3 100644 --- a/libgo/go/net/url/url.go +++ b/libgo/go/net/url/url.go @@ -401,11 +401,12 @@ Error: } func parseAuthority(authority string) (user *Userinfo, host string, err error) { - if strings.Index(authority, "@") < 0 { + i := strings.LastIndex(authority, "@") + if i < 0 { host = authority return } - userinfo, host := split(authority, '@', true) + userinfo, host := authority[:i], authority[i+1:] if strings.Index(userinfo, ":") < 0 { if userinfo, err = unescape(userinfo, encodeUserPassword); err != nil { return diff --git a/libgo/go/net/url/url_test.go b/libgo/go/net/url/url_test.go index d8b2531..75e8abe 100644 --- a/libgo/go/net/url/url_test.go +++ b/libgo/go/net/url/url_test.go @@ -188,6 +188,37 @@ var urltests = []URLTest{ }, "http://user:password@google.com", }, + // unescaped @ in username should not confuse host + { + "http://j@ne:password@google.com", + &URL{ + Scheme: "http", + User: UserPassword("j@ne", "password"), + Host: "google.com", + }, + "http://j%40ne:password@google.com", + }, + // unescaped @ in password should not confuse host + { + "http://jane:p@ssword@google.com", + &URL{ + Scheme: "http", + User: UserPassword("jane", "p@ssword"), + Host: "google.com", + }, + "http://jane:p%40ssword@google.com", + }, + { + "http://j@ne:password@google.com/p@th?q=@go", + &URL{ + Scheme: "http", + User: UserPassword("j@ne", "password"), + Host: "google.com", + Path: "/p@th", + RawQuery: "q=@go", + }, + "http://j%40ne:password@google.com/p@th?q=@go", + }, { "http://www.google.com/?q=go+language#foo", &URL{ |