Last active
May 11, 2018 01:28
-
-
Save freman/b7e33f665d31fccc0a2b443a77d97e1f to your computer and use it in GitHub Desktop.
Make go's cookie jar more url encoding tolerant.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /usr/local/go/src/net/http/cookiejar/jar.go 2018-05-11 10:28:23.000000000 +1000 | |
+++ cooookie/jar.go 2018-05-11 11:27:43.000000000 +1000 | |
@@ -3,7 +3,7 @@ | |
// license that can be found in the LICENSE file. | |
// Package cookiejar implements an in-memory RFC 6265-compliant http.CookieJar. | |
-package cookiejar | |
+package cooookie | |
import ( | |
"errors" | |
@@ -369,6 +369,10 @@ | |
if i == 0 { | |
return "/" // Path has the form "/abc". | |
} | |
+ | |
+ if s, err := url.PathUnescape(path[:i]); err == nil { | |
+ return s | |
+ } | |
return path[:i] // Path is either of form "/abc/xyz" or "/abc/xyz/". | |
} | |
@@ -386,6 +390,8 @@ | |
if c.Path == "" || c.Path[0] != '/' { | |
e.Path = defPath | |
+ } else if path, err := url.PathUnescape(c.Path); err == nil { | |
+ e.Path = path | |
} else { | |
e.Path = c.Path | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment