diff options
author | Matt Jones <mrjones@google.com> | 2011-04-04 15:49:49 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2011-04-04 15:49:49 -0400 |
commit | 5fd0a749874a2784dbef57d4ec9c07429bcc0896 (patch) | |
tree | 5d05db42648f55d99de464956d08cbf62568bade | |
parent | 7d43d00bf56e82489a2ab9db4b64f6ac887feedc (diff) | |
download | go-5fd0a749874a2784dbef57d4ec9c07429bcc0896.tar.gz go-5fd0a749874a2784dbef57d4ec9c07429bcc0896.zip |
http: use upper case hex in URL escaping
According to RFC 3986: "For consistency, URI producers
and normalizers should use uppercase hexadecimal digits
for all percent-encodings." Using lower case characters
makes it incompatible with Google APIs when signing OAuth requests.
R=golang-dev, rsc1, rsc
CC=golang-dev
https://golang.org/cl/4352044
-rw-r--r-- | src/pkg/http/url.go | 4 | ||||
-rw-r--r-- | src/pkg/http/url_test.go | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/http/url.go b/src/pkg/http/url.go index efd90d81eb..0fc0cb2d76 100644 --- a/src/pkg/http/url.go +++ b/src/pkg/http/url.go @@ -213,8 +213,8 @@ func urlEscape(s string, mode encoding) string { j++ case shouldEscape(c, mode): t[j] = '%' - t[j+1] = "0123456789abcdef"[c>>4] - t[j+2] = "0123456789abcdef"[c&15] + t[j+1] = "0123456789ABCDEF"[c>>4] + t[j+2] = "0123456789ABCDEF"[c&15] j += 3 default: t[j] = s[i] diff --git a/src/pkg/http/url_test.go b/src/pkg/http/url_test.go index 0801f7ff3e..d8863f3d3b 100644 --- a/src/pkg/http/url_test.go +++ b/src/pkg/http/url_test.go @@ -490,7 +490,7 @@ var escapeTests = []URLEscapeTest{ }, { " ?&=#+%!<>#\"{}|\\^[]`☺\t", - "+%3f%26%3d%23%2b%25!%3c%3e%23%22%7b%7d%7c%5c%5e%5b%5d%60%e2%98%ba%09", + "+%3F%26%3D%23%2B%25!%3C%3E%23%22%7B%7D%7C%5C%5E%5B%5D%60%E2%98%BA%09", nil, }, } @@ -519,7 +519,7 @@ type UserinfoTest struct { var userinfoTests = []UserinfoTest{ {"user", "password", "user:password"}, {"foo:bar", "~!@#$%^&*()_+{}|[]\\-=`:;'\"<>?,./", - "foo%3abar:~!%40%23$%25%5e&*()_+%7b%7d%7c%5b%5d%5c-=%60%3a;'%22%3c%3e?,.%2f"}, + "foo%3Abar:~!%40%23$%25%5E&*()_+%7B%7D%7C%5B%5D%5C-=%60%3A;'%22%3C%3E?,.%2F"}, } func TestEscapeUserinfo(t *testing.T) { |