From 2dd5fd1fd676c570a13c2ed062fa47a026ca826f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 27 Aug 2021 15:48:27 +0100 Subject: [PATCH 1/2] publicRooms should accept POST as well as GET (#1991) --- federationapi/routing/routing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go index 8f33c766..503e512e 100644 --- a/federationapi/routing/routing.go +++ b/federationapi/routing/routing.go @@ -449,7 +449,7 @@ func Setup( httputil.MakeExternalAPI("federation_public_rooms", func(req *http.Request) util.JSONResponse { return GetPostPublicRooms(req, rsAPI) }), - ).Methods(http.MethodGet) + ).Methods(http.MethodGet, http.MethodPost) v1fedmux.Handle("/user/keys/claim", httputil.MakeFedAPI( "federation_keys_claim", cfg.Matrix.ServerName, keys, wakeup, From 51b119107c972007f5a1bc626758a6229ece14db Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 27 Aug 2021 16:50:30 +0100 Subject: [PATCH 2/2] Don't return nonsense canonical room aliases in the public rooms responses (#1992) --- federationapi/routing/publicrooms.go | 4 +++- roomserver/api/wrapper.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/federationapi/routing/publicrooms.go b/federationapi/routing/publicrooms.go index ddd92c5c..5b9be880 100644 --- a/federationapi/routing/publicrooms.go +++ b/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: - pub.CanonicalAlias = contentVal + 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 diff --git a/roomserver/api/wrapper.go b/roomserver/api/wrapper.go index 2ebe2f64..de66df80 100644 --- a/roomserver/api/wrapper.go +++ b/roomserver/api/wrapper.go @@ -215,7 +215,9 @@ func PopulatePublicRooms(ctx context.Context, roomIDs []string, rsAPI Roomserver case topicTuple: pub.Topic = contentVal case canonicalTuple: - pub.CanonicalAlias = contentVal + 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