Commit c7cc894e authored by David Symonds's avatar David Symonds

net/url: report first error from ParseQuery.

Fixes #4175.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6610068
parent c81293ad
......@@ -521,12 +521,16 @@ func parseQuery(m Values, query string) (err error) {
}
key, err1 := QueryUnescape(key)
if err1 != nil {
err = err1
if err == nil {
err = err1
}
continue
}
value, err1 = QueryUnescape(value)
if err1 != nil {
err = err1
if err == nil {
err = err1
}
continue
}
m[key] = append(m[key], value)
......
......@@ -7,6 +7,7 @@ package url
import (
"fmt"
"reflect"
"strings"
"testing"
)
......@@ -779,3 +780,13 @@ func TestRequestURI(t *testing.T) {
}
}
}
func TestParseFailure(t *testing.T) {
// Test that the first parse error is returned.
const url = "%gh&%ij"
_, err := ParseQuery(url)
errStr := fmt.Sprint(err)
if !strings.Contains(errStr, "%gh") {
t.Errorf(`ParseQuery(%q) returned error %q, want something containing %q"`, url, errStr, "%gh")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment