Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application/x-www-form-urlencoded 参数为空时报错 #57

Open
xusion opened this issue Sep 8, 2019 · 0 comments
Open

application/x-www-form-urlencoded 参数为空时报错 #57

xusion opened this issue Sep 8, 2019 · 0 comments

Comments

@xusion
Copy link

xusion commented Sep 8, 2019

application/x-www-form-urlencoded 参数为空时报错

INFO] 2019/09/08 12:16 200 3.582027ms 127.0.0.1 POST /m/login
12:18:23 app | 2019/09/08 12:18:23 application/x-www-form-urlencoded
12:18:23 app | 2019/09/08 12:18:23 Reading form
12:18:23 app | [WARN] 2019/09/08 12:18 Recovered from a route's Handler('github.com/betacraft/yaag/irisyaag.New.func1')
At Request: 200 /m/login POST 127.0.0.1
Trace: runtime error: index out of range

/usr/local/Cellar/go/1.12.9/libexec/src/runtime/panic.go:522
/usr/local/Cellar/go/1.12.9/libexec/src/runtime/panic.go:44
/Users/xxx/go/src/github.com/betacraft/yaag/middleware/yaagmiddleware.go:139
/Users/xxx/go/src/github.com/betacraft/yaag/middleware/yaagmiddleware.go:83
/Users/xxx/go/src/github.com/betacraft/yaag/irisyaag/middleware.go:23

/Users/xxx/go/src/github.com/betacraft/yaag/middleware/yaagmiddleware.go:139
func ReadPostForm(req *http.Request) map[string]string {
postForm := map[string]string{}
for _, param := range strings.Split(*ReadBody(req), "&") {
value := strings.Split(param, "=")
postForm[value[0]] = value[1]
}
return postForm
}

加粗这一行,很明显没有判断空参数的情况。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant