users@jersey.java.net

RE: [Jersey] Multipart Form And Encoding

From: Jordi Domingo <noseya_at_hotmail.com>
Date: Mon, 2 Nov 2009 14:29:49 +0100

Hi Paul,

1) No

POST /projects/1/vulnerabilities/29/evidences/9/attachments HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://localhost:8080/projects/1/vulnerabilities/29/evidences/9/attachments/new
Cookie: JSESSIONID=4e0e10d1e122370548a6bf6126af
Content-Type: multipart/form-data; boundary=---------------------------112241574819923
Content-Length: 1594

-----------------------------112241574819923
Content-Disposition: form-data; name="name"

Això és una evidència
-----------------------------112241574819923
Content-Disposition: form-data; name="description"

Això és una evidència
-----------------------------112241574819923
Content-Disposition: form-data; name="filename"; filename="favicon.ico"
Content-Type: image/x-icon

......

2) It works in my pc, packed war and will try on preproduction server.

Thanks :)

BTW i found another issue, sending an attachment with firefox and asking for filename fdbp.getContentDisposition().getParameters().get("filename");
i get the filename favicon.ico but with iexplore i get c:favicon.ico. Im not sure if this is something multipart must be aware.

Thanks, I will update when i know how it works in preproduction.

Jordi


> Date: Mon, 2 Nov 2009 12:04:08 +0100
> From: Paul.Sandoz_at_Sun.COM
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] Multipart Form And Encoding
>
> Hi Jordi,
>
> I have verified there is a bug in the FormDataBodyPart.getValue
> method. It is ignoring the charset parameter (if present) on the media
> type.
>
> In fact this method is doing it's own string parsing when it should be
> deferring to the string reader provided of the message body reader.
>
> Can you:
>
> 1) verify there is a charset parameter present on the Content-Type of
> the body part identified as "name"; and
>
> 2) try doing the following and seeing if that works (which depends on
> a charset parameter with a value of "ISO-8859-1" being present)
>
> multiPart.getField("name").getValueAs(String.class);
>
> Paul.
>
>
>
> On Nov 2, 2009, at 11:49 AM, Jordi Domingo wrote:
>
> > Hi,
> >
> > I've got some problems with char encoding using multipart API. I've
> > been able to solve this in my pc using:
> >
> > String name = multiPart.getField("name").getValue();
> > name = new String(name.getBytes("ISO-8859-1"), "UTF-8");
> >
> > But in production it is not working. Chars like àáèéìí ... are shown
> > like ??
> >
> > Any help is appreciated. Thanks,
> >
> > Jordi
> >
> > Entra al Nuevo Canal Motor y descubre por qué los coches más rápidos
> > sólo aparcan en MSN. Nuevo diseño, más completo y abierto a tu
> > opinión.¡Nuevo Canal Motor!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
                                               
_________________________________________________________________
Convierte las fotos que más te gustan en tu nuevo fondo de escritorio para el ordenador. Es fácil y además gratis
http://wallpapers.msn.com/es-es
--_25bb02e6-7070-45b5-9f2f-e3b25861363e_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi Paul,<br><br>1) No<br><br>POST /projects/1/vulnerabilities/29/evidences/9/attachments HTTP/1.1<br>Host: localhost:8080<br>User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14 (.NET CLR 3.5.30729)<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-us,en;q=0.5<br>Accept-Encoding: gzip,deflate<br>Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7<br>Keep-Alive: 300<br>Proxy-Connection: keep-alive<br>Referer: http://localhost:8080/projects/1/vulnerabilities/29/evidences/9/attachments/new<br>Cookie: JSESSIONID=4e0e10d1e122370548a6bf6126af<br>Content-Type: multipart/form-data; boundary=---------------------------112241574819923<br>Content-Length: 1594<br><br>-----------------------------112241574819923<br>Content-Disposition: form-data; name="name"<br><br>Això és una evidència<br>-----------------------------112241574819923<br>Content-Disposition: form-data; name="description"<br><br>Això és una evidència<br>-----------------------------112241574819923<br>Content-Disposition: form-data; name="filename"; filename="favicon.ico"<br>Content-Type: image/x-icon<br><br>......<br><br>2) It works in my pc, packed war and will try on preproduction server. <br><br>Thanks :)<br><br>BTW i found another issue, sending an attachment with firefox and asking for filename fdbp.getContentDisposition().getParameters().get("filename");<br>i get the filename favicon.ico but with iexplore i get c:favicon.ico. Im not sure if this is something multipart must be aware.<br><br>Thanks, I will update when i know how it works in preproduction.<br><br>Jordi<br><br><br>&gt; Date: Mon, 2 Nov 2009 12:04:08 +0100<br>&gt; From: Paul.Sandoz@Sun.COM<br>&gt; To: users@jersey.dev.java.net<br>&gt; Subject: Re: [Jersey] Multipart Form And Encoding<br>&gt; <br>&gt; Hi Jordi,<br>&gt; <br>&gt; I have verified there is a bug in the FormDataBodyPart.getValue <br>&gt; method. It is ignoring the charset parameter (if present) on the media <br>&gt; type.<br>&gt; <br>&gt; In fact this method is doing it's own string parsing when it should be <br>&gt; deferring to the string reader provided of the message body reader.<br>&gt; <br>&gt; Can you:<br>&gt; <br>&gt; 1) verify there is a charset parameter present on the Content-Type of <br>&gt; the body part identified as "name"; and<br>&gt; <br>&gt; 2) try doing the following and seeing if that works (which depends on <br>&gt; a charset parameter with a value of "ISO-8859-1" being present)<br>&gt; <br>&gt; multiPart.getField("name").getValueAs(String.class);<br>&gt; <br>&gt; Paul.<br>&gt; <br>&gt; <br>&gt; <br>&gt; On Nov 2, 2009, at 11:49 AM, Jordi Domingo wrote:<br>&gt; <br>&gt; &gt; Hi,<br>&gt; &gt;<br>&gt; &gt; I've got some problems with char encoding using multipart API. I've <br>&gt; &gt; been able to solve this in my pc using:<br>&gt; &gt;<br>&gt; &gt; String name = multiPart.getField("name").getValue();<br>&gt; &gt; name = new String(name.getBytes("ISO-8859-1"), "UTF-8");<br>&gt; &gt;<br>&gt; &gt; But in production it is not working. Chars like àáèéìí ... are shown <br>&gt; &gt; like ??<br>&gt; &gt;<br>&gt; &gt; Any help is appreciated. Thanks,<br>&gt; &gt;<br>&gt; &gt; Jordi<br>&gt; &gt;<br>&gt; &gt; Entra al Nuevo Canal Motor y descubre por qué los coches más rápidos <br>&gt; &gt; sólo aparcan en MSN. Nuevo diseño, más completo y abierto a tu <br>&gt; &gt; opinión.¡Nuevo Canal Motor!<br>&gt; <br>&gt; <br>&gt; ---------------------------------------------------------------------<br>&gt; To unsubscribe, e-mail: users-unsubscribe@jersey.dev.java.net<br>&gt; For additional commands, e-mail: users-help@jersey.dev.java.net<br>&gt; <br> <br /><hr />Entra al Nuevo Canal Motor y descubre por qué los coches más rápidos sólo aparcan en MSN. Nuevo diseño, más completo y abierto a tu opinión. <a href='http://motor.es.msn.com/' target='_new'>¡Nuevo Canal Motor! </a></body>
</html>
--_25bb02e6-7070-45b5-9f2f-e3b25861363e_--