Bug 54984 - multipart/form-data is not always read with correct encoding
multipart/form-data is not always read with correct encoding
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.40
PC Linux
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-05-16 11:15 UTC by Per Holmberg
Modified: 2013-05-26 20:05 UTC (History)
0 users



Attachments
Multipart demo war (3.65 KB, application/octet-stream)
2013-05-22 11:36 UTC, Per Holmberg
Details
Multipart demo source (2.46 KB, application/zip)
2013-05-22 11:42 UTC, Per Holmberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Per Holmberg 2013-05-16 11:15:20 UTC
The bug occurs when form data is posted as multipart/form-data and using Servlet 3 API to get posted files.
In a servlet, if we set the encoding:

request.setCharacterEncoding("UTF-8");

Then invoke:

request.getParts()

And then invoke:

String text = request.getParameter("sometextfield");

UTF-8 characters in the text have been garbled.

Order of method calls are significant, if a getParameter is called before getParts, the correct encoding will be used.
However, the order which you invoke the methods should not matter.
Comment 1 Christopher Schultz 2013-05-21 20:15:35 UTC
Can you post a simple test-case as a WAR (including source) to reproduce this?
Comment 2 Per Holmberg 2013-05-22 11:36:44 UTC
Created attachment 30311 [details]
Multipart demo war
Comment 3 Per Holmberg 2013-05-22 11:42:32 UTC
Created attachment 30312 [details]
Multipart demo source
Comment 4 Violeta Georgieva 2013-05-26 20:05:28 UTC
Thanks for the report.
Fixed in trunk and 7.0.x and will be included in 7.0.41 onwards.