-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Issue Description
When using Echo.Reverse() to generate URLs to other handlers, the resulting URL is not correctly encoded. This can mean that the URLs generated are not valid.
For example, if I pass in a value of "abc?def" as a parameter to Echo.Reverse(), I'd expect the resulting URL to be "abc%3Fdef". Instead it's just "abc?def", which then means that the resulting URL is wrong - the "?def" becomes the start of the query string and not part of the path parameter.
Checklist
- Dependencies installed
- No typos
- Searched existing issues and docs
Expected behaviour
The parameters passed in to the URL should be URL encoded.
Actual behaviour
The parameters are not URL encoded.
Working code to debug
package main
import (
"github.com/labstack/echo/v4"
)
func main() {
server := echo.New()
server.Add("GET", "/example/:value", func (c echo.Context) error {
return c.String(200, c.Echo().Reverse("example_route", c.Param("value")));
}).Name = "example_route";
server.Start(":8000");
}
Then call with:
-> % http localhost:8000/example/abc%3fdef
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: text/plain; charset=UTF-8
Date: Fri, 29 Apr 2022 18:01:35 GMT
/example/abc?def
-> % http localhost:8000/example/abc?def
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: text/plain; charset=UTF-8
Date: Fri, 29 Apr 2022 18:01:35 GMT
/example/abc
Version/commit
- github.com/labstack/echo/v4 v4.7.2