]> Cypherpunks repositories - gostls13.git/commitdiff
http: use upper case hex in URL escaping
authorMatt Jones <mrjones@google.com>
Mon, 4 Apr 2011 19:49:49 +0000 (15:49 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 4 Apr 2011 19:49:49 +0000 (15:49 -0400)
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

src/pkg/http/url.go
src/pkg/http/url_test.go

index efd90d81eb187f101062000f38fe02f0c54b85af..0fc0cb2d76ee2703ca244f890879e6b33373dbef 100644 (file)
@@ -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]
index 0801f7ff3e82ab55d593c1cfb8e05f9a8f32e1cf..d8863f3d3b5751ad0bd695ef5c70a1a6647dbc95 100644 (file)
@@ -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) {