Skip to content

Commit cd87fb1

Browse files
bircniclaude
andcommitted
Also restore %3A to : in Matrix room ID URL path
Matrix room IDs are of the form !localpart:server. Both ! and : are valid unencoded path segment characters per RFC 3986, but url.PathEscape encodes both. Restore : alongside ! so the full room ID is preserved. Co-Authored-By: Nicolas <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7cf8b40 commit cd87fb1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

routers/web/repo/setting/webhook.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,13 @@ func matrixHookParams(ctx *context.Context) webhookParams {
454454
form := web.GetForm(ctx).(*forms.NewMatrixHookForm)
455455

456456
return webhookParams{
457-
Type: webhook_module.MATRIX,
458-
URL: fmt.Sprintf("%s/_matrix/client/r0/rooms/%s/send/m.room.message", form.HomeserverURL, strings.ReplaceAll(url.PathEscape(form.RoomID), "%21", "!")),
457+
Type: webhook_module.MATRIX,
458+
// Matrix room IDs are of the form "!localpart:server", where "!" and ":" are
459+
// valid unencoded path segment characters per RFC 3986, but url.PathEscape
460+
// encodes them. Restore them so Matrix homeservers can recognise the room ID.
461+
// See https://spec.matrix.org/latest/appendices/#room-ids
462+
URL: fmt.Sprintf("%s/_matrix/client/r0/rooms/%s/send/m.room.message", form.HomeserverURL,
463+
strings.NewReplacer("%21", "!", "%3A", ":").Replace(url.PathEscape(form.RoomID))),
459464
ContentType: webhook.ContentTypeJSON,
460465
HTTPMethod: http.MethodPut,
461466
WebhookForm: form.WebhookForm,

0 commit comments

Comments
 (0)