Nikola Radisic 4cacd2e044
fix(proxy): preserve raw encoded preview path across proxy hops (#4449)
* fix(proxy): preserve raw encoded preview path across proxy hops

Closes #4448

Signed-off-by: Nikola Radisic <radisicc@yahoo.com>

* fix(proxy): update copyright headers per repo convention

Signed-off-by: Nikola Radisic <radisicc@yahoo.com>

* fix(proxy): use commonproxy.RawParam helper in daemon toolbox proxy

apps/daemon/pkg/toolbox/proxy/proxy.go:27-30 inlined the raw-path
extraction logic but omitted two guards that exist in the shared helper:

  1. Empty-string early return: if decodedParam == "" { return "" }
  2. Bounds check: if prefixLen < 0 || prefixLen > len(escapedFull) { return decodedParam }

Without these guards, a mismatch between ctx.Request.URL.Path and
ctx.Param("path") (e.g. due to double-encoding or an unusual router
configuration) would cause an out-of-bounds slice panic instead of
falling back gracefully to the decoded form.

Root cause: the file is in package proxy, so importing
github.com/daytonaio/common-go/pkg/proxy without an alias would cause a
name collision. The inline copy was added to work around the collision
rather than using an aliased import.

Fix: import the shared package as commonproxy and delegate to
commonproxy.RawParam(ctx, "path"). The aliased import compiles cleanly
under the go.work workspace (daemon and common-go are both workspace
members) — the same pattern is already used in apps/runner. Both the
bounds check and the empty-string guard in RawParam are now in effect
here too.

Co-authored-by: Mirko Džaja <mirkodzja0@gmail.com>
Signed-off-by: Nikola Radisic <radisicc@yahoo.com>

---------

Signed-off-by: Nikola Radisic <radisicc@yahoo.com>
Co-authored-by: Mirko Džaja <mirkodzja0@gmail.com>
2026-04-17 12:58:10 +02:00
..
2025-09-22 15:17:53 +02:00