dust4j
dust4j copied to clipboard
Response ContentLength is invalid with 2-byte UTF-8 symbols in template
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