|
Anton,
No. The problem is not for a character at middle of array. This is actualy problem of spliting big byte array to bufferes (you will see LinkedList buffers in this class). So, the big buffer can be converted via new String(bigbuffer, encoding) with no problems, but if you will split it by several smal buffers (per 8192 bytes) you can get small buffer, and you cannot now simple call new String(smallbuffer, encoding) - it is a error. In other words: byte[] bigbuffer = bigText.getBytes("UTF-8"); List<byte[]> buffersPer8192Bytes = splitBuffer(bigbuffer); So, the expression: out.write(new String(bigbuffer, "UTF-8")); Is not the same as: out.write(new String(buffersPer8192Bytes.get(0), "UTF-8")); out.write(new String(buffersPer8192Bytes.get(1), "UTF-8")); ... out.write(new String(buffersPer8192Bytes.get(buffersPer8192Bytes.size() - 1), "UTF-8")); About your question. I'm changed only lines where was code like: new String(bytes, 0, length, encoding) Thanks! Hi Alexey,
Thanks for the feedback! I think we mean exactly the same thing. When you changed: new String(bytes, 0, length, encoding) what did you change this to? Cheers, Thanks for the work you have put into this issue. I can verify that the issue exists.
It will affect people using double byte characters AND where certain web work tags output more than greater than 8K. Can you please give us some "places" where you see this invalid encoding happening. We want to ensure we have covered all the areas where this can happen. We think it mainly happens when people input > 8K of data into say a text field but we want to make sure we haven't missed any other areas that may be affected. Raised http://jira.opensymphony.com/browse/WW-1495
Attached is the example of application (test.zip) that affected with this bug.
This is the Struts 2 application, but it also uses the FastByteArrayOutputStream class. There are 2 JSPs: test.jsp and test.inc that included into test.jsp as "<s:include value="test.inc">". Struts's include tag uses the FastByteArrayOutputStream for copy content of test.inc into the response stream. When you call the page like http://localhost:8080/test/Test.do ааааааааааааа��ааааааааааааааа P.S. Alexey's patch really fix this bug. Related Struts 2 issue: https://issues.apache.org/struts/browse/WW-2412
WebWork has been updated to include patched code and JIRA now depends on the new code
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thank you for the patch!
As far as I can see, the problem is that we get an array of bytes, and if the last byte falls somewhere in the middle of a multi-byte character, the conversion does not work. Is this so? This happens even if JIRA is run with UTF-8 encoding (in Administration -> General Configuration -> Character Encoding)?
I am sorry, but I am traveling and I do not have webwork source readily available. May I ask if you have changed:
to:
Does this mean that the code is dependent on the default encoding of the operating system? And will only work if JIRA is also run with the same encoding (in Administration -> General Configuration -> Character Encoding) as the operating system?
Please accept my apologies for not being able to compare your fix with the current webwork source. I am just really interested in this bug and would really appreciate if you could answer the above questions.
Cheers,
Anton