1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 20:00:01 +00:00

api: Invalid JSON is a client-side error

This commit is contained in:
katnyaa 2017-05-23 13:19:07 +01:00
parent 517f5c48e6
commit aa0d7f702f

View file

@ -85,7 +85,11 @@ def v2_api_upload():
request_data_field = flask.request.form.get('torrent_data')
if request_data_field is None:
return flask.jsonify({'errors': ['missing torrent_data field']}), 400
request_data = json.loads(request_data_field)
try:
request_data = json.loads(request_data_field)
except json.decoder.JSONDecodeError:
return flask.jsonify({'errors': ['unable to parse valid JSON in torrent_data']}), 400
# Map api keys to upload form fields
for key, default in UPLOAD_API_DEFAULTS.items():