Details
Description
There is problem in the way how multibyte UTF-8 characters are handled at end of chunk in the method org.mortbay.jetty.AbstractGenerator.OutputWriter.write(char[] s,int offset, int length).
When multibyte UTF-8 character (for example á - \u00E1) is last character which can fit into "bytes" buffer, it is printed two times to output. One times at the end of buffer, but than this code
if (chunk-i>buffer.length-bytes)
chunk=buffer.length-bytes+i;
cuts the chunk (it is right in the other places - we spend two or more bytes form "bytes" buffer, so we must shorten number of chars which can fir teh buffer). But when this cut occurs at the end of "for (int i = 0; i < chunk; i++)" cycle, this shortcuting of chunk appears like we didn't write last char into buffer. So it is written again in next cycle of OutputWrite.write() call.
I think condition
if (chunk-i>buffer.length-bytes)
chunk=buffer.length-bytes+i;
should be properly
if (chunk-i>buffer.length-bytes && buffer.length-bytes>0)
chunk=buffer.length-bytes+i;
Activity
| Field | Original Value | New Value |
|---|---|---|
| Attachment | ServletTest1java [ 25992 ] |
| Assignee | Greg Wilkins [ gregw ] |
| Resolution | Fixed [ 1 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 6.1.2rc1 [ 13230 ] |
| Attachment | ServletTest2.java [ 26032 ] |
| Resolution | Fixed [ 1 ] | |
| Status | Resolved [ 5 ] | Reopened [ 4 ] |
| Resolution | Fixed [ 1 ] | |
| Status | Reopened [ 4 ] | Resolved [ 5 ] |