summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-06-26 15:12:02 +0100
committerGitHub <noreply@github.com>2017-06-26 15:12:02 +0100
commitd04d672a80a95e7ee1f59b6189f5d5d369f28964 (patch)
treeb10505a656e8fd89f8606ef388b48dbfa961eb00 /synapse
parentMerge pull request #2304 from matrix-org/erikj/users_share_fix (diff)
parentRemove unused variables (diff)
downloadsynapse-d04d672a80a95e7ee1f59b6189f5d5d369f28964.tar.xz
Merge pull request #2290 from matrix-org/erikj/ensure_round_trip
Reject local events that don't round trip the DB
Diffstat (limited to 'synapse')
-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..24c9ffdb20 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)
+            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: