summary refs log tree commit diff
path: root/synapse/events/utils.py
diff options
context:
space:
mode:
authorAaron Raimist <aaron@raim.ist>2021-08-26 11:07:58 -0500
committerGitHub <noreply@github.com>2021-08-26 17:07:58 +0100
commit40f619eaa54d2391deccec473fc0f655c379e766 (patch)
treeb6c4e3f1ece03cd04584f8680f945f4a6c61ea19 /synapse/events/utils.py
parentRemove pushers when deleting 3pid from account (#10581) (diff)
downloadsynapse-40f619eaa54d2391deccec473fc0f655c379e766.tar.xz
Validate new m.room.power_levels events (#10232)
Signed-off-by: Aaron Raimist <aaron@raim.ist>
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r--synapse/events/utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index b6da2f60af..738a151cef 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -32,6 +32,9 @@ from . import EventBase
 #       the literal fields "foo\" and "bar" but will instead be treated as "foo\\.bar"
 SPLIT_FIELD_REGEX = re.compile(r"(?<!\\)\.")
 
+CANONICALJSON_MAX_INT = (2 ** 53) - 1
+CANONICALJSON_MIN_INT = -CANONICALJSON_MAX_INT
+
 
 def prune_event(event: EventBase) -> EventBase:
     """Returns a pruned version of the given event, which removes all keys we
@@ -505,7 +508,7 @@ def validate_canonicaljson(value: Any):
     * NaN, Infinity, -Infinity
     """
     if isinstance(value, int):
-        if value <= -(2 ** 53) or 2 ** 53 <= value:
+        if value < CANONICALJSON_MIN_INT or CANONICALJSON_MAX_INT < value:
             raise SynapseError(400, "JSON integer out of range", Codes.BAD_JSON)
 
     elif isinstance(value, float):