mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-13 18:00:00 +08:00
fix: ignore empty form values in http request (#4542)
This commit is contained in:
@@ -35,6 +35,16 @@ func GetFormValues(r *http.Request) (map[string]any, error) {
|
||||
for name, values := range r.Form {
|
||||
filtered := make([]string, 0, len(values))
|
||||
for _, v := range values {
|
||||
// ignore empty values, especially for optional int parameters
|
||||
// e.g. /api?ids=
|
||||
// e.g. /api
|
||||
// type Req struct {
|
||||
// IDs []int `form:"ids,optional"`
|
||||
// }
|
||||
if len(v) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if n < maxFormParamCount {
|
||||
filtered = append(filtered, v)
|
||||
n++
|
||||
|
||||
Reference in New Issue
Block a user