sanitize bbox parameter (#266)

This commit is contained in:
Tom Kralidis
2019-10-02 19:11:47 +00:00
parent 8709fbb43c
commit e6e637beae
2 changed files with 14 additions and 0 deletions
+9
View File
@@ -467,6 +467,15 @@ class API(object):
return headers_, 400, json.dumps(exception)
except AttributeError:
bbox = []
try:
[float(c) for c in bbox]
except ValueError:
exception = {
'code': 'InvalidParameterValue',
'description': 'bbox values must be numbers'
}
LOGGER.error(exception)
return headers_, 400, json.dumps(exception)
LOGGER.debug('Processing datetime parameter')
# TODO: pass datetime to query as a `datetime` object
+5
View File
@@ -197,6 +197,11 @@ def test_get_features(config, api_):
assert code == 400
rsp_headers, code, response = api_.get_features(
req_headers, {'bbox': '1,2,3,4c'}, 'obs')
assert code == 400
rsp_headers, code, response = api_.get_features(
req_headers, {'f': 'html'}, 'obs')
assert rsp_headers['Content-Type'] == 'text/html'