Don't return nonsense canonical room aliases in the public rooms responses
MODIFY
federationapi/routing/publicrooms.go
federationapi/routing/publicrooms.go
@@ -156,7 +156,9 @@ func fillInRooms(ctx context.Context, roomIDs []string, rsAPI roomserverAPI.Room
case topicTuple:
pub.Topic = contentVal
case canonicalTuple:
+ if _, _, err := gomatrixserverlib.SplitID('#', contentVal); err == nil {
pub.CanonicalAlias = contentVal
+ }
case visibilityTuple:
pub.WorldReadable = contentVal == "world_readable"
// need both of these to determine whether guests can join

MODIFY
roomserver/api/wrapper.go
roomserver/api/wrapper.go
@@ -215,7 +215,9 @@ func PopulatePublicRooms(ctx context.Context, roomIDs []string, rsAPI Roomserver
case topicTuple:
pub.Topic = contentVal
case canonicalTuple:
+ if _, _, err := gomatrixserverlib.SplitID('#', contentVal); err == nil {
pub.CanonicalAlias = contentVal
+ }
case visibilityTuple:
pub.WorldReadable = contentVal == "world_readable"
// need both of these to determine whether guests can join

Don't return nonsense canonical room aliases in the public rooms responses (#1992)