JETTY-1153 Default charset/encoding of HTTP POST requests
This commit is contained in:
parent
a7eabf0757
commit
7908c4e825
|
@ -4,6 +4,7 @@ jetty-7.4.4-SNAPSHOT
|
|||
+ 350397 SelectChannelConnector does not shutdown gracefully
|
||||
+ 351039 Forward dispatch should retain locale
|
||||
+ 351199 HttpServletResponse.encodeURL() wrongly encodes an url without path when cookies are disabled
|
||||
+ JETTY-1153 Default charset/encoding of HTTP POST requests
|
||||
+ JETTY-1380 Jetty Rewrite example does not work in Hightide
|
||||
|
||||
jetty-7.4.3.v20110701 01 July 2011
|
||||
|
|
|
@ -507,7 +507,14 @@ public class UrlEncoded extends MultiMap
|
|||
public static void decodeTo(InputStream in, MultiMap map, String charset, int maxLength)
|
||||
throws IOException
|
||||
{
|
||||
if (charset==null || StringUtil.__UTF8.equalsIgnoreCase(charset))
|
||||
//no charset present, use the configured default
|
||||
if (charset==null)
|
||||
{
|
||||
charset=ENCODING;
|
||||
}
|
||||
|
||||
|
||||
if (StringUtil.__UTF8.equalsIgnoreCase(charset))
|
||||
{
|
||||
decodeUtf8To(in,map,maxLength);
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
@ -28,6 +29,19 @@ import org.junit.Test;
|
|||
*/
|
||||
public class URLEncodedTest
|
||||
{
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
static
|
||||
{
|
||||
/*
|
||||
* Uncomment to set setting the System property to something other than the default of UTF-8.
|
||||
* Beware however that you will have to @Ignore all the other tests other than testUrlEncodedStream!
|
||||
|
||||
System.setProperty("org.eclipse.jetty.util.UrlEncoding.charset", StringUtil.__ISO_8859_1);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
@Test
|
||||
public void testUrlEncoded() throws UnsupportedEncodingException
|
||||
|
@ -160,6 +174,7 @@ public class URLEncodedTest
|
|||
{StringUtil.__UTF16,StringUtil.__UTF16},
|
||||
};
|
||||
|
||||
|
||||
for (int i=0;i<charsets.length;i++)
|
||||
{
|
||||
ByteArrayInputStream in = new ByteArrayInputStream("name\n=value+%30&name1=&name2&n\u00e3me3=value+3".getBytes(charsets[i][0]));
|
||||
|
@ -184,7 +199,28 @@ public class URLEncodedTest
|
|||
}
|
||||
else
|
||||
assertTrue("Charset Shift_JIS not supported by jvm", true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
@Test
|
||||
public void testCharsetViaSystemProperty ()
|
||||
throws Exception
|
||||
{
|
||||
/*
|
||||
* Uncomment to test setting a non-UTF-8 default character encoding using the SystemProperty org.eclipse.jetty.util.UrlEncoding.charset.
|
||||
* You will also need to uncomment the static initializer that sets this SystemProperty near the top of this file.
|
||||
|
||||
|
||||
ByteArrayInputStream in3 = new ByteArrayInputStream("name=libell%E9".getBytes(StringUtil.__ISO_8859_1));
|
||||
MultiMap m3 = new MultiMap();
|
||||
UrlEncoded.decodeTo(in3, m3, null, -1);
|
||||
assertEquals("stream name", "libell\u00E9", m3.getString("name"));
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue