aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/api
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2016-01-25 17:26:33 +0700
committerChristopher Allan Webber <cwebber@dustycloud.org>2016-01-25 12:09:19 -0800
commit7c9af02ab627da4642e34db2e152e5a218165aad (patch)
treef202dd9922d40161f63d97aa7a51b056e38e66a8 /mediagoblin/api
parent63b5959fd456cbb6529286c46336a318e2b15289 (diff)
downloadmediagoblin-7c9af02ab627da4642e34db2e152e5a218165aad.tar.lz
mediagoblin-7c9af02ab627da4642e34db2e152e5a218165aad.tar.xz
mediagoblin-7c9af02ab627da4642e34db2e152e5a218165aad.zip
Fix #5408 - ignore non-int offset in api feed
In the same fashion limit=BAD fallsback to the default value, fallback to zero when offset=WORSE. Also add test coverage verifying limit/offset do the right thing. Signed-off-by: Loic Dachary <loic@dachary.org>
Diffstat (limited to 'mediagoblin/api')
-rw-r--r--mediagoblin/api/views.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/mediagoblin/api/views.py b/mediagoblin/api/views.py
index dcd04cd6..74181fde 100644
--- a/mediagoblin/api/views.py
+++ b/mediagoblin/api/views.py
@@ -587,7 +587,12 @@ def feed_endpoint(request, outbox=None):
outbox = outbox.limit(limit)
# Offset (default: no offset - first <count> result)
- outbox = outbox.offset(request.args.get("offset", 0))
+ offset = request.args.get("offset", 0)
+ try:
+ offset = int(offset)
+ except ValueError:
+ offset = 0
+ outbox = outbox.offset(offset)
# Build feed.
for activity in outbox: