Author: markt
Date: Wed Jan 20 16:14:52 2016
New Revision: 1725749
URL: http://svn.apache.org/viewvc?rev=1725749&view=rev
Log:
Update Tomcat's internal fork of codec to codec/trunk
Modified:
tomcat/trunk/java/org/apache/tomcat/util/codec/ (props changed)
tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java
tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
Propchange: tomcat/trunk/java/org/apache/tomcat/util/codec/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 20 16:14:52 2016
@@ -1 +1 @@
-/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec:1459201-1682326
+/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec:1459201-1725746
Modified: tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java?rev=1725749&r1=1725748&r2=1725749&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java Wed Jan
20 16:14:52 2016
@@ -111,13 +111,15 @@ public class Base64 extends BaseNCodec {
* http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/
*/
private static final byte[] DECODE_TABLE = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2,
3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23,
- 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+ // 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
00-0f
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
10-1f
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, //
20-2f + - /
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, //
30-3f 0-9
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, //
40-4f A-O
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, //
50-5f P-Z _
+ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, //
60-6f a-o
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 //
70-7a p-z
};
/**
@@ -437,17 +439,16 @@ public class Base64 extends BaseNCodec {
// We're done.
context.eof = true;
break;
- } else {
- if (b >= 0 && b < DECODE_TABLE.length) {
- final int result = DECODE_TABLE[b];
- if (result >= 0) {
- context.modulus = (context.modulus+1) %
BYTES_PER_ENCODED_BLOCK;
- context.ibitWorkArea = (context.ibitWorkArea <<
BITS_PER_ENCODED_BYTE) + result;
- if (context.modulus == 0) {
- buffer[context.pos++] = (byte)
((context.ibitWorkArea >> 16) & MASK_8BITS);
- buffer[context.pos++] = (byte)
((context.ibitWorkArea >> 8) & MASK_8BITS);
- buffer[context.pos++] = (byte)
(context.ibitWorkArea & MASK_8BITS);
- }
+ }
+ if (b >= 0 && b < DECODE_TABLE.length) {
+ final int result = DECODE_TABLE[b];
+ if (result >= 0) {
+ context.modulus = (context.modulus+1) %
BYTES_PER_ENCODED_BLOCK;
+ context.ibitWorkArea = (context.ibitWorkArea <<
BITS_PER_ENCODED_BYTE) + result;
+ if (context.modulus == 0) {
+ buffer[context.pos++] = (byte) ((context.ibitWorkArea
>> 16) & MASK_8BITS);
+ buffer[context.pos++] = (byte) ((context.ibitWorkArea
>> 8) & MASK_8BITS);
+ buffer[context.pos++] = (byte) (context.ibitWorkArea &
MASK_8BITS);
}
}
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java?rev=1725749&r1=1725748&r2=1725749&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java Wed
Jan 20 16:14:52 2016
@@ -415,16 +415,36 @@ public abstract class BaseNCodec impleme
*
* @param pArray
* a byte array containing binary data
- * @return A byte array containing only the basen alphabetic character data
+ * @return A byte array containing only the base N alphabetic character
data
*/
@Override
public byte[] encode(final byte[] pArray) {
if (pArray == null || pArray.length == 0) {
return pArray;
}
+ return encode(pArray, 0, pArray.length);
+ }
+
+ /**
+ * Encodes a byte[] containing binary data, into a byte[] containing
+ * characters in the alphabet.
+ *
+ * @param pArray
+ * a byte array containing binary data
+ * @param offset
+ * initial offset of the subarray.
+ * @param length
+ * length of the subarray.
+ * @return A byte array containing only the base N alphabetic character
data
+ * @since 1.11
+ */
+ public byte[] encode(final byte[] pArray, int offset, int length) {
+ if (pArray == null || pArray.length == 0) {
+ return pArray;
+ }
final Context context = new Context();
- encode(pArray, 0, pArray.length, context);
- encode(pArray, 0, EOF, context); // Notify encoder of EOF.
+ encode(pArray, offset, length, context);
+ encode(pArray, offset, EOF, context); // Notify encoder of EOF.
final byte[] buf = new byte[context.pos - context.readPos];
readResults(buf, 0, buf.length, context);
return buf;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]