History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STS-328
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Ben Gunter
Reporter: Jens Illig
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Stripes

CommonsMultipartWrapper did not use character encoding from HttpServletRequest

Created: 18/Jan/07 07:55 AM   Updated: 30/Apr/07 05:31 AM
Component/s: None
Affects Version/s: Release 1.4.2
Fix Version/s: Release 1.4.3

Environment:
commons-fileupload-1.1,
mozilla-firefox 1.5.0.7,
ISO-8859-15-System-locale
UTF-8 jsp-encoding (also set in web.xml for stripes' LocalePicker)


 Description  « Hide
Posting the same HTML-Form with or without a single stripes:file parameter affected whether stripes:text-RequestParameter-StringProperties were injected into the ActionBean with right or wrong character encoding (German Umlaute). After some debugging I found out that net.sourceforge.stripes.controller.multipart.CommonsMultipartWrapper does:
[...]
for (FileItem item : items) {
                // If it's a form field, add the string value to the list
                if (item.isFormField()) {
                    List<String> values = params.get(item.getFieldName());
                    if (values == null) {
                        values = new ArrayList<String>();
                        params.put(item.getFieldName(), values);
                    }
                    values.add(item.getString());
                }
                // Else store the file param
                else {
                    files.put(item.getFieldName(), item);
                }
            }
[...]

in its build method. I changed

      [...]
      values.add(item.getString());
      [...]

to

      [...]
      values.add( (request.getCharacterEncoding() != null) ? item.getString(request.getCharacterEncoding()) : item.getString() );
      [...]

and everythink works fine for me.

 All   Comments   Change History      Sort Order:
Ben Gunter [03/Mar/07 08:01 PM]
The code now uses the request's character encoding if one is specified.