-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add event size checks similar to Synapse #400
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #400 +/- ##
==========================================
+ Coverage 56.95% 58.47% +1.52%
==========================================
Files 50 51 +1
Lines 6632 6993 +361
==========================================
+ Hits 3777 4089 +312
- Misses 2498 2517 +19
- Partials 357 387 +30
☔ View full report in Codecov by Sentry. |
if err := checkID(input.RoomID(), "room", '!'); err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check eventID
like synapse does here?
eventV2.go
Outdated
if input.StateKey() != nil { | ||
if l := len(*input.StateKey()); l > maxIDLength { | ||
if l := utf8.RuneCountInString(*input.StateKey()); l > maxIDLength { | ||
return EventValidationError{ | ||
Code: EventValidationTooLarge, | ||
Message: fmt.Sprintf("gomatrixserverlib: state key is too long, length %d bytes > maximum %d bytes", l, maxIDLength), | ||
} | ||
} | ||
} | ||
|
||
_, persistable := lenientByteLimitRoomVersions[input.Version()] | ||
|
||
if l := len(input.Type()); l > maxIDLength { | ||
return EventValidationError{ | ||
Code: EventValidationTooLarge, | ||
Message: fmt.Sprintf("gomatrixserverlib: event type is too long, length %d bytes > maximum %d bytes", l, maxIDLength), | ||
Persistable: persistable, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should comment the reasoning behind the 2 checks like synapse does.
Companion to matrix-org/gomatrixserverlib#400 This tries to mimic the logic found in Synapse, as dropping events can break rooms (and we may end up in endless loops..)
This tries to mimic the logic from Synapse to allow specific events.