From 4cb67fe72c5e248d3a6e5d46a9909463d4dd8866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 8 May 2019 17:52:27 +0200 Subject: [PATCH] =?UTF-8?q?=E2=98=94=20Don't=20allow=20NaN=20in=20generate?= =?UTF-8?q?d=20JSON=20output=20on=20APIs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See also #3022 --- src/octoprint/server/util/flask.py | 2 +- src/octoprint/server/util/tornado.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 93f68802c..a5b5eace4 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -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' ) diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index d8bc724e7..d04e403f8 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -36,7 +36,7 @@ def fix_json_encode(): import json def fixed_json_encode(value): - return json.dumps(value, default=JsonEncoding.encode).replace("