summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-06-19 11:33:40 +0100
committerErik Johnston <erik@matrix.org>2017-06-19 11:33:40 +0100
commitfcf01dd88e738e5745c17c7740e0d72b8bbbcb66 (patch)
tree13ab63b61df6674baab2a71c15cfbb09032e0dea /synapse/handlers
parentadd missing boolean to synapse_port_db (diff)
downloadsynapse-fcf01dd88e738e5745c17c7740e0d72b8bbbcb66.tar.xz
Reject local events that don't round trip the DB
Diffstat (limited to '')
-rw-r--r--synapse/handlers/message.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index a04f634c5c..5585ee85cf 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -34,6 +34,7 @@ from canonicaljson import encode_canonical_json
 
 import logging
 import random
+import ujson
 
 logger = logging.getLogger(__name__)
 
@@ -498,6 +499,14 @@ class MessageHandler(BaseHandler):
             logger.warn("Denying new event %r because %s", event, err)
             raise err
 
+        # Ensure that we can round trip before trying to persist in db
+        try:
+            dump = ujson.dumps(event.content)
+            load = ujson.loads(dump)
+        except:
+            logger.exception("Failed to encode content: %r", event.content)
+            raise
+
         yield self.maybe_kick_guest_users(event, context)
 
         if event.type == EventTypes.CanonicalAlias: