Skip to content

Commit

Permalink
Merge pull request #1643 from aa1143/master
Browse files Browse the repository at this point in the history
#1642: add check the values array length, avoid panic: index out of range
  • Loading branch information
kataras authored Sep 23, 2020
2 parents a8e263c + 7c1502b commit 6509a3d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -1813,8 +1813,11 @@ func (ctx *Context) PostValueDefault(name string, def string) string {
if err != nil {
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,
Expand Down

0 comments on commit 6509a3d

Please sign in to comment.