dust4j icon indicating copy to clipboard operation
dust4j copied to clipboard

Response ContentLength is invalid with 2-byte UTF-8 symbols in template

Open grolfcry opened this issue 12 years ago • 0 comments

For example - Cyrillic word "Привет".

Bug in DustCompilingFilter class in line

response.setContentLength(template.length());

You have to use

response.setContentLength(template.getBytes().length());

You use ByteOutputStream in response writer and when you write 2-bytes symbols to out (like "Привет") - length will be greater then template.length() (6) and will be equals to template.getBytes().length().

And when browser read the response stream, some last bytes will be lost and you get a error.

Please fix it

grolfcry avatar Jun 25 '13 14:06 grolfcry