-
Notifications
You must be signed in to change notification settings - Fork 38.7k
SPR-16590: getParameterValues would work incorrectly #1740
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
Conversation
@jasonjoo2010 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@jasonjoo2010 Thank you for signing the Contributor License Agreement! |
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 PR is incomplete without any tests. Just mentioning it in case you want to make it complete.
@@ -87,14 +89,28 @@ public String getParameter(String name) { | |||
} | |||
return super.getParameter(name); | |||
} | |||
|
|||
public String[] mergeTwoParameterValues(String[] val1, String[] val2) { |
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.
Need not be a public method.
return val1; | ||
} | ||
//merge them together before return | ||
String[] merged = Arrays.copyOf(val2, val1.length + val2.length); |
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.
It's counter-intuitive for a method that merges to arrays, two put the second one first.
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.
So i fix them and add getParameterValues test in CommonsMultipartResolverTests.
But i used forced pushing to avoid unnecessary commits and found i cannot reopen this.
Should i open another PR?
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.
Force push is fine. Just keep the branch updated, no need to re-create the PR.
Affected method:
DefaultMultipartHttpServletRequest::getParameterValues
DefaultMultipartHttpServletRequest::getParameterMap
getParameterValues is used to return multi values of a same key in request, including query string, post contents.
And DefaultMultipartHttpServletRequest would be used instead of default servlet wrapper when using "multipart/form-data" post method to realize including vars in multipart body. And there is a problem in its getter in dealing values of same keys. It will not merge them to values in query string.
It can be reproduced by following steps:
You will get a parameter map like:
And you will get:
Let's sit down to discuss whether fix it?