ASF Bugzilla – Attachment 28257 Details for
Bug 52579
Tomcat5.5.35+Java1.5 cannot return proper value of a request parameter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
new implementation of ByteChunk.toStringInternal()
patch.txt (text/plain), 1.75 KB, created by
Keiichi Fujino
on 2012-02-03 09:32:27 UTC
(
hide
)
Description:
new implementation of ByteChunk.toStringInternal()
Filename:
MIME Type:
Creator:
Keiichi Fujino
Created:
2012-02-03 09:32:27 UTC
Size:
1.75 KB
patch
obsolete
>Index: java/org/apache/tomcat/util/buf/ByteChunk.java >=================================================================== >--- java/org/apache/tomcat/util/buf/ByteChunk.java (revision 1206324) >+++ java/org/apache/tomcat/util/buf/ByteChunk.java (working copy) >@@ -23,6 +23,9 @@ > import java.nio.ByteBuffer; > import java.nio.CharBuffer; > import java.nio.charset.Charset; >+import java.nio.charset.CharsetDecoder; >+import java.nio.charset.CoderResult; >+import java.nio.charset.CodingErrorAction; > > /* > * In a server it is very important to be able to operate on >@@ -510,12 +513,20 @@ > if (charset == null) { > charset = DEFAULT_CHARSET; > } >- // new String(byte[], int, int, Charset) takes a defensive copy of the >- // entire byte array. This is expensive if only a small subset of the >- // bytes will be used. The code below is from Apache Harmony. >- CharBuffer cb; >- cb = charset.decode(ByteBuffer.wrap(buff, start, end-start)); >- return new String(cb.array(), cb.arrayOffset(), cb.length()); >+ CharsetDecoder dec = charset.newDecoder().onMalformedInput( >+ CodingErrorAction.REPLACE).onUnmappableCharacter( >+ CodingErrorAction.REPLACE); >+ char[] charAry = new char[(int) ((end - start) * dec.maxCharsPerByte())]; >+ >+ CharBuffer cbuff = CharBuffer.wrap(charAry); >+ CoderResult result; >+ >+ result = dec.decode(ByteBuffer.wrap(buff, start, end - start), cbuff, true); >+ if (!result.isUnderflow()) return new String(buff, start, end-start); >+ result = dec.flush(cbuff); >+ if (!result.isUnderflow()) return new String(buff, start, end-start); >+ >+ return new String(charAry, 0, cbuff.position()); > } > > public int getInt()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 52579
:
28251
|
28252
| 28257 |
28274