☔ Don't allow NaN in generated JSON output on APIs

See also #3022
This commit is contained in:
Gina Häußge committed 2019-05-08 17:52:27 +02:00
1 parent b79fc94a4e
commit 4cb67fe72c
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -271,7 +271,7 @@ def fix_flask_jsonify():
data = args or kwargs
return current_app.response_class(
dumps(data, indent=indent, separators=separators) + '\n',
dumps(data, indent=indent, separators=separators, allow_nan=False) + '\n',
mimetype='application/json'
)
+1 -1
View File
@@ -36,7 +36,7 @@ def fix_json_encode():
import json
def fixed_json_encode(value):
return json.dumps(value, default=JsonEncoding.encode).replace("</", "<\\/")
return json.dumps(value, default=JsonEncoding.encode, allow_nan=False).replace("</", "<\\/")
import tornado.escape
tornado.escape.json_encode = fixed_json_encode