Revert "Fix event size checks (#13710)"

This reverts commit fab495a9e1.

As noted in
https://github.com/matrix-org/synapse/pull/13710#issuecomment-1298396007:

> We want to see this change land for the protocol's sake (and plan to
  un-revert it) but want to give this a little more time before releasing
  this.
This commit is contained in:
David Robertson 2022-11-01 11:47:09 +00:00
parent b922b54b61
commit 9473ebb9e7
No known key found for this signature in database
GPG key ID: 903ECE108A39DEDD
2 changed files with 5 additions and 6 deletions

View file

@ -1 +0,0 @@
Fix a long-standing bug where Synapse would count codepoints instead of bytes when validating the size of some fields.

View file

@ -342,15 +342,15 @@ def check_state_dependent_auth_rules(
def _check_size_limits(event: "EventBase") -> None: def _check_size_limits(event: "EventBase") -> None:
if len(event.user_id.encode("utf-8")) > 255: if len(event.user_id) > 255:
raise EventSizeError("'user_id' too large") raise EventSizeError("'user_id' too large")
if len(event.room_id.encode("utf-8")) > 255: if len(event.room_id) > 255:
raise EventSizeError("'room_id' too large") raise EventSizeError("'room_id' too large")
if event.is_state() and len(event.state_key.encode("utf-8")) > 255: if event.is_state() and len(event.state_key) > 255:
raise EventSizeError("'state_key' too large") raise EventSizeError("'state_key' too large")
if len(event.type.encode("utf-8")) > 255: if len(event.type) > 255:
raise EventSizeError("'type' too large") raise EventSizeError("'type' too large")
if len(event.event_id.encode("utf-8")) > 255: if len(event.event_id) > 255:
raise EventSizeError("'event_id' too large") raise EventSizeError("'event_id' too large")
if len(encode_canonical_json(event.get_pdu_json())) > MAX_PDU_SIZE: if len(encode_canonical_json(event.get_pdu_json())) > MAX_PDU_SIZE:
raise EventSizeError("event too large") raise EventSizeError("event too large")