You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2008/10/16 16:41:44 UTC

[jira] Created: (WICKET-1876) RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec

RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec
-------------------------------------------------------------------------------

                 Key: WICKET-1876
                 URL: https://issues.apache.org/jira/browse/WICKET-1876
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.3.4
         Environment: Any
            Reporter: Martin Grigorov


RequestUtils.decodeParameters(String, ValueMap) (and probably RequestUtils.decodeUrlParameters(String, Map)) fills a (Value)Map with values of type java.lang.String while it
has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].

How I get to this: 
mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].

A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-1876) RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec

Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1876?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov updated WICKET-1876:
------------------------------------

    Attachment: WICKET-1876.patch.txt

It seems that RequestUtils.decodeUrlParameters(String, Map) does the right thing. It is the same as RequestUtils.decodeParameters(String, ValueMap) but makes the right thing with the values.

The attached patch replaces all usages of decodeParameters() with decodeUrlParameters().
It does solve my problem.

Run the tests after applying it because they fail locally (but this could be caused by other changed files here...).

> RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-1876
>                 URL: https://issues.apache.org/jira/browse/WICKET-1876
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.4
>         Environment: Any
>            Reporter: Martin Grigorov
>         Attachments: WICKET-1876.patch.txt
>
>
> RequestUtils.decodeParameters(String, ValueMap) (and probably RequestUtils.decodeUrlParameters(String, Map)) fills a (Value)Map with values of type java.lang.String while it
> has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].
> How I get to this: 
> mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
> Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].
> A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1876) RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec

Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659671#action_12659671 ] 

Martin Grigorov commented on WICKET-1876:
-----------------------------------------

Hi Juergen,

Thanks for looking into this !

Do you mind to change MockHttpServletRequest.setUrl(String) to use decodeUrlParameters() instead of decodeParameters(). Otherwise my tests fail will ClassCastException complaining that the values in the map are java.lang.String while it expects [java.lang.String.

> RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-1876
>                 URL: https://issues.apache.org/jira/browse/WICKET-1876
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.4
>         Environment: Any
>            Reporter: Martin Grigorov
>            Assignee: Juergen Donnerstag
>             Fix For: 1.4-RC2
>
>         Attachments: WICKET-1876.patch.txt
>
>
> RequestUtils.decodeParameters(String, ValueMap) fills a (Value)Map with values of type java.lang.String while it
> has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].
> How I get to this: 
> mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
> Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].
> A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1876) RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659690#action_12659690 ] 

Juergen Donnerstag commented on WICKET-1876:
--------------------------------------------

do have a test case?

> RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-1876
>                 URL: https://issues.apache.org/jira/browse/WICKET-1876
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.4
>         Environment: Any
>            Reporter: Martin Grigorov
>            Assignee: Juergen Donnerstag
>             Fix For: 1.4-RC2
>
>         Attachments: WICKET-1876.patch.txt
>
>
> RequestUtils.decodeParameters(String, ValueMap) fills a (Value)Map with values of type java.lang.String while it
> has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].
> How I get to this: 
> mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
> Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].
> A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-1876) RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec

Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1876?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov updated WICKET-1876:
------------------------------------

    Description: 
RequestUtils.decodeParameters(String, ValueMap) fills a (Value)Map with values of type java.lang.String while it
has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].

How I get to this: 
mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].

A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

  was:
RequestUtils.decodeParameters(String, ValueMap) (and probably RequestUtils.decodeUrlParameters(String, Map)) fills a (Value)Map with values of type java.lang.String while it
has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].

How I get to this: 
mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].

A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 


> RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-1876
>                 URL: https://issues.apache.org/jira/browse/WICKET-1876
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.4
>         Environment: Any
>            Reporter: Martin Grigorov
>         Attachments: WICKET-1876.patch.txt
>
>
> RequestUtils.decodeParameters(String, ValueMap) fills a (Value)Map with values of type java.lang.String while it
> has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].
> How I get to this: 
> mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
> Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].
> A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WICKET-1876) RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec

Posted by "Juergen Donnerstag (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1876?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag resolved WICKET-1876.
----------------------------------------

       Resolution: Invalid
    Fix Version/s: 1.4-RC2
         Assignee: Juergen Donnerstag

ServletRequest provides two related methods: String getParameter(String) and String[] getParameterValues(String). Since PageParameters implements ValueMap the respective methods are String getString(String) and String[] params.getStringArray(String)

> RequestUtils.decodeParameters(String, ValueMap) doesn't follow the Servlet spec
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-1876
>                 URL: https://issues.apache.org/jira/browse/WICKET-1876
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.4
>         Environment: Any
>            Reporter: Martin Grigorov
>            Assignee: Juergen Donnerstag
>             Fix For: 1.4-RC2
>
>         Attachments: WICKET-1876.patch.txt
>
>
> RequestUtils.decodeParameters(String, ValueMap) fills a (Value)Map with values of type java.lang.String while it
> has to fill values of type String[] because by Servlet API java.servlet.ServletRequest.getParameterValues(String) returns String[].
> How I get to this: 
> mockHttpServletRequest.setUrl("http://dummy.com?param1=value1") -> this calls RequestUtils.decodeParameters(queryString, parameters);
> Later when I do mockHttpServletRequest.getParameterMap() and iterate over it I expect the values to be of type String[].
> A trivial (and wrong) fix would be to put "new String[] {currentValue}" in the map. The proper fix is to collect all values per parameter name and create an array of them. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.