Conversation
| // The creator field was removed in room version 11 (MSC4239). | ||
| n, err := strconv.Atoi(string(roomVer)) | ||
| if err != nil || n < 11 { | ||
| content["creator"] = creator | ||
| } |
There was a problem hiding this comment.
Feels like something that should be handled by this kind of thing:
iRoomVer := gomatrixserverlib.MustGetRoomVersion(roomVer)
if iRoomVer.CreatorInCreateEvent() {
CreatorInCreateEvent doesn't exist yet but aligns with the other things we have there like DomainlessRoomIDs and PrivilegedCreators
See #840 for how v12 rooms were added
There was a problem hiding this comment.
that's a good idea! done, and also added a change there matrix-org/gomatrixserverlib#465
Signed-off-by: Thomas Traineau t.traineau@famedly.com
6af47bf to
1feb361
Compare
| // The creator field was removed in room version 11 (MSC4239). | ||
| if defaultVerN < 11 { | ||
| must.Equal(t, ev.Get("content").Get("creator").Str, alice.UserID, "wrong content.creator") | ||
| } |
There was a problem hiding this comment.
Looks like we can use the same CreatorInCreateEvent check in this other spot as well
| ver := alice.GetDefaultRoomVersion(t) | ||
| // This test crafts a "bad" event which state_key is 280 bytes but only 70 | ||
| // codepoints. | ||
| // | ||
| // Room version 11 in Synapse switched from using codepoints to using | ||
| // bytes. Which means the 280-byte state_key would be rejected immediately. | ||
| // Use room version 10 in that case so the codepoint-based limit is in effect. | ||
| // | ||
| // Since upgrading a room (for example from v10 to v11) won't carry the event | ||
| // (a new room is created), we don't have to worry about v10 room events in a v11 | ||
| // room. | ||
| // | ||
| // So this test is essentially skipped for any default room v11 or higher. | ||
| verNum, _ := strconv.Atoi(string(ver)) | ||
| if verNum >= 11 { | ||
| ver = gomatrixserverlib.RoomVersion("10") | ||
| } |
There was a problem hiding this comment.
This seems like yet another case that we should handle with a new assert iRoomVer.StrictEventByteLimits() check
You can see how we do this in Synapse synapse/event_auth.py#L487-L499
| ver := alice.GetDefaultRoomVersion(t) | ||
| // This test crafts a "bad" event which state_key is 280 bytes but only 70 | ||
| // codepoints. | ||
| // | ||
| // Room version 11 in Synapse switched from using codepoints to using | ||
| // bytes. Which means the 280-byte state_key would be rejected immediately. | ||
| // Use room version 10 in that case so the codepoint-based limit is in effect. | ||
| // | ||
| // Since upgrading a room (for example from v10 to v11) won't carry the event | ||
| // (a new room is created), we don't have to worry about v10 room events in a v11 | ||
| // room. | ||
| // | ||
| // So this test is essentially skipped for any default room v11 or higher. | ||
| verNum, _ := strconv.Atoi(string(ver)) | ||
| if verNum >= 11 { | ||
| ver = gomatrixserverlib.RoomVersion("10") | ||
| } |
There was a problem hiding this comment.
Seems like this test would be better if we just always used room version 10 🤔 . The current setup is only better if we're trying to support homeservers that don't support room version 10 yet (do we care about that?)
| ver := alice.GetDefaultRoomVersion(t) | |
| // This test crafts a "bad" event which state_key is 280 bytes but only 70 | |
| // codepoints. | |
| // | |
| // Room version 11 in Synapse switched from using codepoints to using | |
| // bytes. Which means the 280-byte state_key would be rejected immediately. | |
| // Use room version 10 in that case so the codepoint-based limit is in effect. | |
| // | |
| // Since upgrading a room (for example from v10 to v11) won't carry the event | |
| // (a new room is created), we don't have to worry about v10 room events in a v11 | |
| // room. | |
| // | |
| // So this test is essentially skipped for any default room v11 or higher. | |
| verNum, _ := strconv.Atoi(string(ver)) | |
| if verNum >= 11 { | |
| ver = gomatrixserverlib.RoomVersion("10") | |
| } | |
| // This test crafts a "bad" event which state_key is 280 bytes but only 70 | |
| // codepoints. | |
| // | |
| // Room version 11 in Synapse switched from using codepoints to using | |
| // bytes. Which means the 280-byte state_key would be rejected immediately. | |
| // Use room version 10 in that case so the codepoint-based limit is in effect. | |
| // | |
| // Since upgrading a room (for example from v10 to v11) won't carry the event | |
| // (a new room is created), we don't have to worry about v10 room events in a v11 | |
| // room. | |
| // | |
| // So this test is essentially skipped for any default room v11 or higher. | |
| ver = gomatrixserverlib.RoomVersion("10") |
| // hashes will not be the same. | ||
| "complement_entropy": util.RandomString(18), | ||
| } | ||
| if gomatrixserverlib.MustGetRoomVersion(gomatrixserverlib.RoomVersion(roomVer)).CreatorInCreateEvent() { |
There was a problem hiding this comment.
TODO: Wait for matrix-org/gomatrixserverlib#465 to merge and update the gomatrixserverlib version in this PR
creatorfield anymore during room creation, which broke the tests.state_keylength in events (from codepoints to bytes) at room v11, which broke the tests.This PR fixes those issues, making complement work with room v11 as default.
Related to element-hq/synapse#18680