Repository navigation
Commit 2a99e93
authored
fix(httpapi): percent-decode the registry {id} on search, refresh, edit and remove (#1774)
## Problem
Custom registry ids are user-chosen (`registry add-source --id ...`) and
aren't restricted to a slug, so they can contain characters such as `:`
or `/`. The CLI builds these URLs with `url.PathEscape` and the Web UI
with `encodeURIComponent`, so those characters reach the server
percent-encoded. chi routes on `RawPath`, which means `chi.URLParam(r,
"id")` returns the encoded form (`acme%3Ainternal`) and the exact-match
registry lookup misses.
As a result, a registry added as `acme:internal` can't be searched,
refreshed, edited or removed. `handleAddFromRegistry` already decodes
the same param (MCP-1056); the other four handlers don't.
## Fix
Wrap `{id}` in the existing `decodePathParam` in
`handleSearchRegistryServers`, `handleRefreshRegistryCache`,
`handleEditRegistrySource` and `handleRemoveRegistrySource`.
## Test
`TestRegistryRoutes_DecodeIDParam` sends `acme%3Ainternal` to all four
routes and checks the id passed to the controller. On main all four
subtests receive `acme%3Ainternal`; with this change they receive
`acme:internal`. `go test -count=1 ./internal/httpapi/` passes.
Made with [Cursor](https://cursor.com)1 parent 599a2ee commit 2a99e93
2 files changed
Lines changed: 71 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6419 | 6419 | | |
6420 | 6420 | | |
6421 | 6421 | | |
6422 | | - | |
| 6422 | + | |
6423 | 6423 | | |
6424 | 6424 | | |
6425 | 6425 | | |
| |||
6675 | 6675 | | |
6676 | 6676 | | |
6677 | 6677 | | |
6678 | | - | |
| 6678 | + | |
6679 | 6679 | | |
6680 | 6680 | | |
6681 | 6681 | | |
| |||
6714 | 6714 | | |
6715 | 6715 | | |
6716 | 6716 | | |
6717 | | - | |
| 6717 | + | |
6718 | 6718 | | |
6719 | 6719 | | |
6720 | 6720 | | |
| |||
6753 | 6753 | | |
6754 | 6754 | | |
6755 | 6755 | | |
6756 | | - | |
| 6756 | + | |
6757 | 6757 | | |
6758 | 6758 | | |
6759 | 6759 | | |
| |||
0 commit comments