Merge pull request #1643 from aa1143/master

#1642: add check the values array length, avoid panic: index out of range
This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-09-23 19:18:47 +03:00 committed by GitHub
commit 6509a3d0c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1813,8 +1813,11 @@ func (ctx *Context) PostValueDefault(name string, def string) string {
if err != nil { if err != nil {
return def // it returns "def" even if it's empty here. return def // it returns "def" even if it's empty here.
} }
if len(values) > 0 {
return values[len(values)-1]
}
return values[len(values)-1] return def
} }
// PostValue returns the last parsed form data from POST, PATCH, // PostValue returns the last parsed form data from POST, PATCH,