mirror of https://github.com/golang/go.git
net/url: report first error from ParseQuery.
Fixes #4175. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6610068
This commit is contained in:
parent
c81293ada7
commit
c7cc894ef5
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue