Fix links retrieval handler allowing negative limit and offset values
This commit is contained in:
parent
458ae28901
commit
2baa74d520
1 changed files with 2 additions and 2 deletions
|
|
@ -53,7 +53,7 @@ func allRetrievalHandler(ctx echo.Context, serv Service) error {
|
||||||
limit := 20
|
limit := 20
|
||||||
if v := ctx.QueryParam("limit"); v != "" {
|
if v := ctx.QueryParam("limit"); v != "" {
|
||||||
num, err := strconv.Atoi(v)
|
num, err := strconv.Atoi(v)
|
||||||
if err != nil {
|
if err != nil || num < 0 {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid limit value.")
|
return echo.NewHTTPError(http.StatusBadRequest, "Invalid limit value.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ func allRetrievalHandler(ctx echo.Context, serv Service) error {
|
||||||
offset := 0
|
offset := 0
|
||||||
if v := ctx.QueryParam("offset"); v != "" {
|
if v := ctx.QueryParam("offset"); v != "" {
|
||||||
num, err := strconv.Atoi(v)
|
num, err := strconv.Atoi(v)
|
||||||
if err != nil {
|
if err != nil || num < 0 {
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid offset value.")
|
return echo.NewHTTPError(http.StatusBadRequest, "Invalid offset value.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue