From 45b6b6abe70e029195affffa0dea4b2800985c79 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Sat, 7 Nov 2009 05:42:15 +0000 Subject: [PATCH] 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 --- VERSION.txt | 1 + .../org/eclipse/jetty/server/HttpWriter.java | 5 +++ .../eclipse/jetty/server/HttpWriterTest.java | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/VERSION.txt b/VERSION.txt index fd22173c191..ae4f457a096 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -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 diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpWriter.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpWriter.java index 00739f02705..f25089bf730 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpWriter.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpWriter.java @@ -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 diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java index 9ee05fb421c..d2516e12a88 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java @@ -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