Multipart Parser bug with multiple FileParts named the same name

2008-04-16 Thread Jerry DuVal
Is this a bug?

When a MultipartHttpServletRequest parses the values using MultipartParser
it puts the Inline Parts into a Vector, but when parsing FileParts it just
puts them into the parts hashtable.  The problem with this is when a
Request has multiple FileParts named the same, the parsed parts for the
FilePart will always be the value of the last parsed FilePart.  Using the
example HTML below, if you attached different files to All.foo for each row,
the MultipartParser would only have 1 value for All.foo ( the value from the
second row ) instead of a vector.  Let me know what you think, I can create
a patch. 

Example HTML:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html xmlns:page=http://pace2020.com/appbox/page/2.0;
xmlns=http://www.w3.org/1999/xhtml;
head
meta http-equiv=Content-Type content=text/html; charset=UTF-8/
/head
body
form method=post name=appboxForm
action=/estimating/object/Customer/list?tab=0
enctype=multipart/form-data
table id=All
tbody
tr
td
input name=All.primaryKey type=hidden
value=FOO'BAR/
/td
td
input name=All.foo class=filefield
type=file id=d1508e107/
/td
/tr
tr
td
input name=All.primaryKey type=hidden
value=HOUSE/
/td
td
input name=All.foo class=filefield
type=file id=d1508e144/
/td
/tr   
/tbody
/table
input name=appbox-continuation-id type=hidden
value=1a0b71687548296a197026662a6366591a211b00/
input type=hidden name=appbox_currentTab
id=appbox_currentTab value=0/
/form
/body
/html


http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apach
e/cocoon/servlet/multipart/MultipartParser.java?revision=638212view=markup

private void parseFilePart(TokenStream in, Hashtable headers) IOException,
MultipartException 

At the bottom of the method

String name = (String)headers.get(name);
if (oversized) {
this.parts.put(name, new RejectedPart(headers, length,
this.contentLength, this.maxUploadSize));
} else if (file == null) {
byte[] bytes = ((ByteArrayOutputStream) out).toByteArray();
this.parts.put(name, new PartInMemory(headers, bytes));
} else {
this.parts.put(name, new PartOnDisk(headers, file));
}

Thanks in Advance,

Jerry DuVal
Pace Systems Group, Inc.
800.624.5999
www.Pace2020.com




Re: Multipart Parser bug with multiple FileParts named the same name

2008-04-16 Thread Joerg Heinicke

On 16.04.2008 10:11, Jerry DuVal wrote:


Is this a bug?


Feature :) More an inconsistency than an actual bug. I for myself would 
not rely on the correct order of both All.primaryKey and All.foo.



When a MultipartHttpServletRequest parses the values using MultipartParser
it puts the Inline Parts into a Vector, but when parsing FileParts it just
puts them into the parts hashtable.  The problem with this is when a
Request has multiple FileParts named the same, the parsed parts for the
FilePart will always be the value of the last parsed FilePart.  Using the
example HTML below, if you attached different files to All.foo for each row,
the MultipartParser would only have 1 value for All.foo ( the value from the
second row ) instead of a vector.  Let me know what you think, I can create
a patch. 


http://marc.info/?l=xml-cocoon-cvsm=120840321224196w=4
http://marc.info/?l=xml-cocoon-cvsm=120840325524262w=4

Please test the new code in SVN. Thanks for your report.

Joerg