URL encode room alias before sending to AS

This commit is contained in:
Andrew Morgan 2018-06-12 16:20:12 +01:00
parent 1c2cb21935
commit 94be181b0e

View file

@ -20,6 +20,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"net/http" "net/http"
"net/url"
"github.com/matrix-org/dendrite/appservice/api" "github.com/matrix-org/dendrite/appservice/api"
"github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common"
@ -51,8 +52,9 @@ func (a *AppServiceQueryAPI) RoomAliasExists(
for _, appservice := range a.Cfg.Derived.ApplicationServices { for _, appservice := range a.Cfg.Derived.ApplicationServices {
if appservice.URL != "" && appservice.IsInterestedInRoomAlias(request.Alias) { if appservice.URL != "" && appservice.IsInterestedInRoomAlias(request.Alias) {
// The full path to the rooms API, includes hs token // The full path to the rooms API, includes hs token
apiURL := appservice.URL + URL, err := url.Parse(appservice.URL)
remoteAppServiceRoomAliasExistsPath + request.Alias + "?access_token=" + appservice.HSToken URL.Path += request.Alias
apiURL := URL.String() + "?access_token=" + appservice.HSToken
// Send a request to each application service. If one responds that it has // Send a request to each application service. If one responds that it has
// created the room, immediately return. // created the room, immediately return.