diff options
author | Loic Dachary <loic@dachary.org> | 2016-01-25 17:26:33 +0700 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2016-01-25 12:09:19 -0800 |
commit | 7c9af02ab627da4642e34db2e152e5a218165aad (patch) | |
tree | f202dd9922d40161f63d97aa7a51b056e38e66a8 /mediagoblin/api | |
parent | 63b5959fd456cbb6529286c46336a318e2b15289 (diff) | |
download | mediagoblin-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.py | 7 |
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: |