JETTY-1144 fixed multi-byte character overflow
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1030 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
07c6830d6c
commit
45b6b6abe7
|
@ -23,6 +23,7 @@ jetty-7.0.1-SNAPSHOT
|
|||
+ JETTY-1125 TransparentProxy incorrectly configured for test webapp
|
||||
+ JETTY-1129 Filter control characters out of StdErrLog
|
||||
+ JETTY-1135 Handle connection closed before accepted during JVM bug work around
|
||||
+ JETTY-1144 fixed multi-byte character overflow
|
||||
+ COMETD-34 Support Baeyux MBean
|
||||
+ Fixed XSS issue in CookieDump demo servlet.
|
||||
+ Improved start.jar usage text for properties
|
||||
|
|
|
@ -162,6 +162,11 @@ public class HttpWriter extends Writer
|
|||
if ((code & 0xffffff80) == 0)
|
||||
{
|
||||
// 1b
|
||||
if (bytes>=buffer.length)
|
||||
{
|
||||
chars=i;
|
||||
break;
|
||||
}
|
||||
buffer[bytes++]=(byte)(code);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -6,6 +6,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.jetty.http.AbstractGenerator;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.Buffers;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
|
@ -115,4 +116,34 @@ public class HttpWriterTest extends TestCase
|
|||
_writer.write("How now Brown cow");
|
||||
assertEquals("How now ?rown cow",new String(_bytes.asArray(),StringUtil.__ISO_8859_1));
|
||||
}
|
||||
|
||||
public void testOutput()
|
||||
throws Exception
|
||||
{
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
HttpFields fields = new HttpFields();
|
||||
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
|
||||
|
||||
HttpGenerator hb = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
|
||||
|
||||
hb.setResponse(200,"OK");
|
||||
|
||||
HttpOutput output = new HttpOutput(hb,10000);
|
||||
HttpWriter writer = new HttpWriter(output);
|
||||
writer.setCharacterEncoding(StringUtil.__UTF8);
|
||||
|
||||
char[] chars = new char[1024];
|
||||
for (int i=0;i<chars.length;i++)
|
||||
chars[i]=(char)('0'+(i%10));
|
||||
chars[0]='\u0553';
|
||||
writer.write(chars);
|
||||
|
||||
hb.completeHeader(fields,true);
|
||||
hb.flush(10000);
|
||||
String response = new String(endp.getOut().asArray());
|
||||
assertTrue(response.startsWith("HTTP/1.1 200 OK\r\nContent-Length: 1025\r\n\r\n\u05531234567890"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue