Fix encoding for Matrix Webhooks#37190
Conversation
|
There are different standards: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#description Only
|
|
btw: is it possible to find some "matrix official documents" for this encoding? |
|
Good point — For documentation: the Matrix spec defines room IDs at https://spec.matrix.org/latest/appendices/#room-ids. The underlying reason both characters are safe to leave unencoded is RFC 3986 §3.3 — Attribution: Nicolas (bircni) with claude-sonnet-4-6 |
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: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Maybe also interesting: https://spec.matrix.org/latest/appendices/#matrix-uri-scheme |
|
Those are matrix.to links. It might not be the same as direct ones. And for the comment maybe stick to |
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
|
thanks @wxiaoguang - I was too fast xD |
I am not sure, maybe need to find some real matrix users to try. |
well it's less broken than before and if it is still broken someone will complain. |
|
Maybe it needs to migrate to the latest API, and the encoding problem might should have been fixed. https://spec.matrix.org/v1.18/client-server-api/#sending-events-to-a-room |
Yes looks like our implementation is kinda old - but this should be solved in another issue and by someone who has matrix knowledge |
Thats why I was confused when you said we don't need lol |
|
this is so confusing the deeper you dive |
Well, just beucase their API design is a mess .... there is no reason to reject encoded characters like |
`url.PathEscape` unnecessarily encodes ! to %21, causing Matrix homeservers to reject the request with 401. Replace %21 back to ! after escaping. Fixes go-gitea#36012 --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Backport #37190 by @bircni `url.PathEscape` unnecessarily encodes ! to %21, causing Matrix homeservers to reject the request with 401. Replace %21 back to ! after escaping. Fixes #36012 Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Nicolas <bircni@icloud.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* main: Add comment for the design of "user activity time" (go-gitea#37195) fix(api): handle missing base branch in PR commits API (go-gitea#37193) Refactor htmx and fetch-action related code (go-gitea#37186) Fix encoding for Matrix Webhooks (go-gitea#37190) Always show owner/repo name in compare page dropdowns (go-gitea#37172) fix(api): handle fork-only commits in compare API (go-gitea#37185) Improve Contributing docs and set a release schedule (go-gitea#37109) Update Nix flake (go-gitea#37183) Remove outdated RunUser logic (go-gitea#37180) Refactor flash message and remove SanitizeHTML template func (go-gitea#37179) Indicate form field readonly via background (go-gitea#37175) Remove dead CSS rules (go-gitea#37173) Fix flaky `TestCatFileBatch/QueryTerminated` test (go-gitea#37159) Implement logout redirection for reverse proxy auth setups (go-gitea#36085) Add missing `//nolint:depguard` (go-gitea#37162)



url.PathEscapeunnecessarily encodes ! to %21, causing Matrix homeservers to reject the request with 401. Replace %21 back to ! after escaping.Fixes #36012