Skip to content

Commit 0dca3d5

Browse files
non-numeric room version check update in remaining places
1 parent 6e7c0af commit 0dca3d5

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

lib/SyTest/Federation/AuthChecks.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ sub _creator_for_create_event
108108

109109
my $room_version = $create_event->{content}{room_version};
110110

111-
# For room version 11+, 'creator' is absent from content, we use sender.
112-
if( defined $room_version and $room_version =~ /\A[0-9]+\z/ and $room_version >= 11 ) {
111+
# For room version 11+ (or unstable/non-numeric versions), 'creator' is absent
112+
# from content; use sender instead.
113+
if( defined $room_version && ( $room_version !~ /\A[0-9]+\z/ || $room_version >= 11 ) ) {
113114
return $create_event->{sender};
114115
}
115116

lib/SyTest/Federation/Room.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ sub create_initial_events
183183
my $create_content = {
184184
defined( $room_version ) ? ( room_version => $room_version ) : (),
185185
};
186-
# Default to old 'creator' field unless room version is a numeric integer >= 11.
186+
# Default to old 'creator' field if no room version is specified, or room version is
187+
# a numeric value <11. Non-numeric (unstable) versions are treated as 11+.
187188
$create_content->{creator} = $creator
188-
unless defined( $room_version ) && $room_version =~ /\A[0-9]+\z/ && $room_version >= 11;
189+
unless defined( $room_version ) && ( $room_version !~ /\A[0-9]+\z/ || $room_version >= 11 );
189190

190191
$self->create_and_insert_event(
191192
type => "m.room.create",

tests/30rooms/01state.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
my $content = $event->{content};
3636
my $room_version = $content->{room_version} // "1";
37-
if( $room_version =~ /\A[0-9]+\z/ && $room_version >= 11 ) {
37+
if( $room_version !~ /\A[0-9]+\z/ || $room_version >= 11 ) {
3838
# Room version 11+: 'creator' must be absent from content.
3939
exists $content->{creator} and
4040
die "Expected no 'creator' key in content for room version $room_version";

0 commit comments

Comments
 (0)