Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whats-this
api
Commits
c97d9277
Commit
c97d9277
authored
5 years ago
by
Dean
Browse files
Options
Downloads
Patches
Plain Diff
version 1.6.4: 400 on negative offset/limit
parent
c4cc52a7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/apierrors/errors.go
+1
-1
1 addition, 1 deletion
lib/apierrors/errors.go
lib/routes/listobjects.go
+6
-6
6 additions, 6 deletions
lib/routes/listobjects.go
main.go
+1
-1
1 addition, 1 deletion
main.go
with
8 additions
and
8 deletions
lib/apierrors/errors.go
+
1
−
1
View file @
c97d9277
...
@@ -33,7 +33,7 @@ var (
...
@@ -33,7 +33,7 @@ var (
InvalidOffsetOrLimit
=
APIError
{
false
,
400
,
"invalid offset or limit query paramters"
,
false
}
InvalidOffsetOrLimit
=
APIError
{
false
,
400
,
"invalid offset or limit query paramters"
,
false
}
// OffsetTooLarge is a 400 bad request error.
// OffsetTooLarge is a 400 bad request error.
Offse
tTooLarge
=
APIError
{
false
,
400
,
"
offse
t is too big"
,
false
}
Limi
tTooLarge
=
APIError
{
false
,
400
,
"
limi
t is too big"
,
false
}
// NoObjectFound is a 404 not found error.
// NoObjectFound is a 404 not found error.
NoObjectFound
=
APIError
{
false
,
404
,
"no object found"
,
false
}
NoObjectFound
=
APIError
{
false
,
404
,
"no object found"
,
false
}
...
...
This diff is collapsed.
Click to expand it.
lib/routes/listobjects.go
+
6
−
6
View file @
c97d9277
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
)
)
// Maximum objects per page
// Maximum objects per page
const
max
Offse
t
=
100
const
max
Limi
t
=
100
// listObjectsResponse is the response format for ListObjects.
// listObjectsResponse is the response format for ListObjects.
type
listObjectsResponse
struct
{
type
listObjectsResponse
struct
{
...
@@ -45,17 +45,17 @@ func ListObjects(w http.ResponseWriter, r *http.Request) {
...
@@ -45,17 +45,17 @@ func ListObjects(w http.ResponseWriter, r *http.Request) {
query
:=
r
.
URL
.
Query
()
query
:=
r
.
URL
.
Query
()
l
:=
query
.
Get
(
"limit"
)
l
:=
query
.
Get
(
"limit"
)
limit
,
err
:=
strconv
.
Atoi
(
l
)
limit
,
err
:=
strconv
.
Atoi
(
l
)
if
err
!=
nil
{
if
err
!=
nil
||
limit
<
0
{
panic
(
apierrors
.
InvalidOffsetOrLimit
)
panic
(
apierrors
.
InvalidOffsetOrLimit
)
}
}
if
limit
>
maxLimit
{
panic
(
apierrors
.
LimitTooLarge
)
}
o
:=
query
.
Get
(
"offset"
)
o
:=
query
.
Get
(
"offset"
)
offset
,
err
:=
strconv
.
Atoi
(
o
)
offset
,
err
:=
strconv
.
Atoi
(
o
)
if
err
!=
nil
{
if
err
!=
nil
||
offset
<
0
{
panic
(
apierrors
.
InvalidOffsetOrLimit
)
panic
(
apierrors
.
InvalidOffsetOrLimit
)
}
}
if
limit
>
maxOffset
{
panic
(
apierrors
.
OffsetTooLarge
)
}
asc
:=
false
asc
:=
false
if
query
.
Get
(
"order"
)
==
"asc"
{
if
query
.
Get
(
"order"
)
==
"asc"
{
asc
=
true
asc
=
true
...
...
This diff is collapsed.
Click to expand it.
main.go
+
1
−
1
View file @
c97d9277
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
const
(
const
(
configLocationUnix
=
"/etc/whats-this/api/config.toml"
configLocationUnix
=
"/etc/whats-this/api/config.toml"
shutdownTimeout
=
10
*
time
.
Second
shutdownTimeout
=
10
*
time
.
Second
version
=
"1.6.
3
"
version
=
"1.6.
4
"
)
)
// printConfiguration iterates through a configuration map[string]interface{}
// printConfiguration iterates through a configuration map[string]interface{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment