Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(238)

Unified Diff: src/pkg/url/url.go

Issue 4973062: code review 4973062: url: handle ; in ParseQuery (Closed)
Patch Set: diff -r ce2e5f44b310 https://go.googlecode.com/hg Created 12 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/http/request_test.go ('k') | src/pkg/url/url_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/url/url.go
===================================================================
--- a/src/pkg/url/url.go
+++ b/src/pkg/url/url.go
@@ -532,20 +532,28 @@
}
func parseQuery(m Values, query string) (err os.Error) {
- for _, kv := range strings.Split(query, "&") {
- if len(kv) == 0 {
+ for query != "" {
+ key := query
+ if i := strings.IndexAny(key, "&;"); i >= 0 {
+ key, query = key[:i], key[i+1:]
+ } else {
+ query = ""
+ }
+ if key == "" {
continue
}
- kvPair := strings.SplitN(kv, "=", 2)
-
- var key, value string
- var e os.Error
- key, e = QueryUnescape(kvPair[0])
- if e == nil && len(kvPair) > 1 {
- value, e = QueryUnescape(kvPair[1])
+ value := ""
+ if i := strings.Index(key, "="); i >= 0 {
+ key, value = key[:i], key[i+1:]
}
- if e != nil {
- err = e
+ key, err1 := QueryUnescape(key)
+ if err1 != nil {
+ err = err1
+ continue
+ }
+ value, err1 = QueryUnescape(value)
+ if err1 != nil {
+ err = err1
continue
}
m[key] = append(m[key], value)
« no previous file with comments | « src/pkg/http/request_test.go ('k') | src/pkg/url/url_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b