Validate websocket JSON before sending
The default json library in python will send infinity values as `Infinity` as described [here](https://docs.python.org/3/library/json.html#json.dump). Check that the JSON is strictly valid before sending it, otherwise throw an exception. This fixes #3875
This commit is contained in:
1 file changed
+3
@@ -589,6 +589,9 @@ class PrinterStateConnection(
|
||||
|
||||
def _do_emit(self, type, payload):
|
||||
try:
|
||||
import json
|
||||
|
||||
_ = json.dumps(octoprint.util.thaw_frozendict({type: payload}), allow_nan=False)
|
||||
self.send({type: payload})
|
||||
except Exception as e:
|
||||
if self._logger.isEnabledFor(logging.DEBUG):
|
||||
|
||||
Reference in new issue
Block a user