mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 08:46:04 -04:00
Be stricter about JSON that is accepted by Synapse (#8106)
This commit is contained in:
parent
d89692ea84
commit
eebf52be06
20 changed files with 85 additions and 62 deletions
|
@ -25,8 +25,18 @@ from synapse.logging import context
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create a custom encoder to reduce the whitespace produced by JSON encoding.
|
||||
json_encoder = json.JSONEncoder(separators=(",", ":"))
|
||||
|
||||
def _reject_invalid_json(val):
|
||||
"""Do not allow Infinity, -Infinity, or NaN values in JSON."""
|
||||
raise json.JSONDecodeError("Invalid JSON value: '%s'" % val)
|
||||
|
||||
|
||||
# Create a custom encoder to reduce the whitespace produced by JSON encoding and
|
||||
# ensure that valid JSON is produced.
|
||||
json_encoder = json.JSONEncoder(allow_nan=False, separators=(",", ":"))
|
||||
|
||||
# Create a custom decoder to reject Python extensions to JSON.
|
||||
json_decoder = json.JSONDecoder(parse_constant=_reject_invalid_json)
|
||||
|
||||
|
||||
def unwrapFirstError(failure):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue