-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set maxParam with SetParamNames #1535
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,8 +60,6 @@ func TestJWTRace(t *testing.T) { | |
|
||
func TestJWT(t *testing.T) { | ||
e := echo.New() | ||
r := e.Router() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be only cleanup and unrelated to the PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fix is the code added in #1463 which triggered #1492. Removed because it is no longer needed in this PR. |
||
r.Add("GET", "/:jwt", func(echo.Context) error { return nil }) | ||
handler := func(c echo.Context) error { | ||
return c.String(http.StatusOK, "test") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to set values without checking for the length of pnames here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Param
checks the length, so it's OK.echo/context.go
Line 298 in f93ba1f
ParamValues
does not check the length, so setting a slice shorter than pnames will panic.echo/context.go
Line 317 in f93ba1f
However, in the documentation it is written to set the same number of values, so it seems to be understood as a specification.
https://echo.labstack.com/guide/testing#setting-path-params
SetParamValues
does not return an error, so if you want to fix it, you should check the length withParamValues
.