Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2290 from matrix-org/erikj/ensure_round_trip
Browse files Browse the repository at this point in the history
Reject local events that don't round trip the DB
  • Loading branch information
erikjohnston authored Jun 26, 2017
2 parents 036f439 + 1bce3e6 commit d04d672
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import logging
import random
import ujson

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -498,6 +499,14 @@ def handle_new_client_event(
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:
Expand Down

0 comments on commit d04d672

Please sign in to comment.