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>
This commit is contained in:
Loic Dachary
2016-01-25 17:26:33 +07:00
committed by Christopher Allan Webber
parent 63b5959fd4
commit 7c9af02ab6
2 changed files with 50 additions and 3 deletions

View File

@@ -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: