-
-
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1535 +/- ##
=======================================
Coverage 84.84% 84.84%
=======================================
Files 28 28
Lines 2165 2165
=======================================
Hits 1837 1837
Misses 213 213
Partials 115 115
Continue to review full report at Codecov.
|
@lammel Can you please help review this? |
@vishr Yes, OK. I'll review the patch later. |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be only cleanup and unrelated to the PR.
Please remove the unrelated fixes, better open a cleanup PR for that.
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.
This fix is the code added in #1463 which triggered #1492.
https://github.com/labstack/echo/pull/1463/files#diff-8c1ede4eff7529ee5a22ed18da7944df
Removed because it is no longer needed in this PR.
go.mod
Outdated
@@ -3,10 +3,11 @@ module github.com/labstack/echo/v4 | |||
go 1.14 | |||
|
|||
require ( | |||
github.com/dgrijalva/jwt-go v3.2.0+incompatible |
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.
The go.mod updates are very likely not required.
Please cleanup your PR to not modify unrelated files.
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.
Fixed!
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.
Looking good overall.
Please cleanup the unrelated files.
Didn't have time for testing or debugging yet, did you do real world testing with this patches?
for i, val := range values { | ||
c.pvalues[i] = val | ||
} | ||
c.pvalues = values |
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.
Line 298 in f93ba1f
if i < len(c.pvalues) { |
ParamValues
does not check the length, so setting a slice shorter than pnames will panic.
Line 317 in f93ba1f
return c.pvalues[:len(c.pnames)] |
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 with ParamValues
.
@lammel Thanks!
Yes! |
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.
Reviewed changes and usage of SetParamValues and SetParamNames.
This helpers are used only for testing and this patch fixes the interactions with the internal echo.maxParam.
Tests are green, test coverage is there. Approved
Fixes #1492