Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327601

Summary: Problem with parsing in MultiPartInputStream with escape codes of special characters
Product: [RT] Jetty Reporter: Tomaž Vajngerl <quikee>
Component: serverAssignee: Jan Bartel <janb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox
Version: 8.0.0   
Target Milestone: 7.1.x   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Tomaž Vajngerl CLA 2010-10-12 14:56:31 EDT
In cases when the browser (Firefox in my case) uses a character set ISO-8859-1 it replaces all non-supported characters with a escape code in form of &#123; This is also true when uploading files with multipart/form-data POST method. The problem is not in the data itself but in the header of multipart/form-data where the filename can have special characters.

In my case the header was: form-data; name="UploadedFile"; filename="Diplomsko Delo Lektorirano KON&#268;NA.doc"

MultiPartInputStream in parse method on the other hand handles the character ";" as a delimiter character between header elements and in case of "Diplomsko Delo Lektorirano KON&#268;NA.doc" it splits the filename in between where the "special" character is present causing later on an StringIndexOutOfBoundsException.

If the character set is UTF-8 however it work as it is supposed to because the "special" characters are not replaced with a escape code, but still the the parsing code should not fail in such a case.
Comment 1 Greg Wilkins CLA 2010-10-12 21:36:31 EDT
Do you know if there is an RFC that describes this encoding and when it is used?
Comment 2 Greg Wilkins CLA 2010-10-12 21:57:12 EDT
Never mind, I think I can ignore that encoding, just so long as I don't ignore the quotes.

I've changed to using quotedStringTokenenizer instead of StringTokenizer and that appears to have done the trick (for a simple unit test).

This is in r2344 of Jetty-7 and will get merged into Jetty-8

Jan - I'll leave this open and assign to you as I don't think this will be an automatic merge into 8 (plus I think there are other multipart changes for 8 to be done).
Comment 3 Jan Bartel CLA 2010-10-25 04:55:48 EDT
This fix has been merged into jetty-8 from jetty-7 via tag jetty-7-to-jetty-8-base-20101025-1.