[enhydra] Possible Bug in MultiPartMimeInputStream

João Paulo Ribeiro <[email protected]> Fri, 23 Sep 2005 16:55:40 +0100
Newsgroups gmane.comp.java.enhydra.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------080906020308050702050106
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Hi!

I found something that i think is bug: in MultipartMimeInputStream when
reading the headers of a multipart request, the byte are autamatically
transformed in String instead of using the correct encoding. This happen
in 5.4.1 and the last enhydra version from CVS (6.5.1?).
The problem is the headers in multipart request have usefull information
like the file name. Not using the correct encoding to transform the
bytes to a String, made the file name appears wtih strange chars on it.

For enhydra 5.4.1 a made a little patch: i just changed one line in the
constructor and added the necessary import.
I changed the line:
String line = new String(bytesToChars(lineBuf,0,n));
to:
String line = new String(lineBuf,0,n,HttpUtils.ENCODING);
And added the:
import javax.servlet.http.HttpUtils;

Now it works well. :)

For 6.5.1 i did not made a patch but it should be something similar like
changing the same line to:
String line = new String(lineBuf,0,n,
comms.request.getHttpServletRequest().getCharacterEncoding());
and add the necessary imports.

I attached the diff for 5.4.1.

I hope this can be usefull.

Best regards.
João Paulo Ribeiro

-- 
João Paulo Ribeiro | Senior Software Engineer
[email protected]

PHONE: + 351 253 305 250
FAX  : + 351 253 305 250
www.mobicomp.com

________________________________________________________________

About Solutions | Wireless World

CONFIDENTIALITY NOTICE: This message, as well as existing attached files, is confidential and intended exclusively for the individual(s) named as addressees. If you are not the intended recipient, you are kindly requested not to make any use whatsoever of its contents and to proceed to the destruction of the message, thereby notifying the sender.
DISCLAIMER: The sender of this message can not ensure the security of its electronic transmission and consequently does not accept liability for any fact which may interfere with the integrity of its content.


--------------080906020308050702050106
Content-Type: text/plain;
 name="diff.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="diff.txt"

32d31
< import javax.servlet.http.HttpUtils;
142c141
<             String line = new String(lineBuf,0,n,HttpUtils.ENCODING);
---
> 	    String line = new String(bytesToChars(lineBuf,0,n));

--------------080906020308050702050106
Content-Type: text/plain; name="message-footer.txt"
Content-Disposition: inline; filename="message-footer.txt"
Content-Transfer-Encoding: 8bit


--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

--------------080906020308050702050106--