[tomcat] branch master updated: Update Codec - no substantive changes

2021-01-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new c9214a0  Update Codec - no substantive changes
c9214a0 is described below

commit c9214a0f18758de37a1fb432cfd25532953ea635
Author: Mark Thomas 
AuthorDate: Fri Jan 15 12:27:10 2021 +

Update Codec - no substantive changes
---
 MERGE.txt |  2 +-
 java/org/apache/tomcat/util/codec/binary/Base64.java  | 10 +-
 java/org/apache/tomcat/util/codec/binary/StringUtils.java |  8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index 58541c1..1c449c7 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -43,7 +43,7 @@ Codec
 Sub-tree:
 src/main/java/org/apache/commons/codec
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
-53c93d0ffccb65d182306c74d1230ce814889dc1 (2020-08-18)
+2e9785b93a2aacedd84abc6a646cdb200940b818 (2021-01-15)
 Note: Only classes required for Base64 encoding/decoding. The rest are removed.
 
 FileUpload
diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
index 2b5c7d4..08d7d34 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -360,8 +360,8 @@ public class Base64 extends BaseNCodec {
  * @since 1.5
  */
 public static boolean isBase64(final byte[] arrayOctet) {
-for (byte b : arrayOctet) {
-if (!isBase64(b) && !isWhiteSpace(b)) {
+for (byte element : arrayOctet) {
+if (!isBase64(element) && !isWhiteSpace(element)) {
 return false;
 }
 }
@@ -428,7 +428,8 @@ public class Base64 extends BaseNCodec {
 private static void validateCharacter(final int emptyBitsMask, final 
Context context) {
 if ((context.ibitWorkArea & emptyBitsMask) != 0) {
 throw new IllegalArgumentException(
-"Last encoded character (before the paddings if any) is a 
valid base 64 alphabet but not a possible value. " +
+"Last encoded character (before the paddings if any) is a 
valid " +
+"base 64 alphabet but not a possible value. " +
 "Expected the discarded bits to be zero.");
 }
 }
@@ -586,8 +587,7 @@ public class Base64 extends BaseNCodec {
 }
 if (lineLength > 0){ // null line-sep forces no chunking rather 
than throwing IAE
 this.encodeSize = BYTES_PER_ENCODED_BLOCK + 
lineSeparator.length;
-this.lineSeparator = new byte[lineSeparator.length];
-System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, 
lineSeparator.length);
+this.lineSeparator = lineSeparator.clone();
 } else {
 this.encodeSize = BYTES_PER_ENCODED_BLOCK;
 this.lineSeparator = null;
diff --git a/java/org/apache/tomcat/util/codec/binary/StringUtils.java 
b/java/org/apache/tomcat/util/codec/binary/StringUtils.java
index 673dd0f..979313b 100644
--- a/java/org/apache/tomcat/util/codec/binary/StringUtils.java
+++ b/java/org/apache/tomcat/util/codec/binary/StringUtils.java
@@ -55,8 +55,8 @@ public class StringUtils {
  *the String to encode, may be {@code null}
  * @return encoded bytes, or {@code null} if the input string was {@code 
null}
  * @throws NullPointerException
- * Thrown if {@link StandardCharsets#UTF_8} is not 
initialized, which should never happen since it is
- * required by the Java platform specification.
+ * Thrown if {@link StandardCharsets#UTF_8} is not 
initialized, which should never happen
+ * since it is required by the Java platform specification.
  * @since As of 1.7, throws {@link NullPointerException} instead of 
UnsupportedEncodingException
  * @see http://download.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html;>Standard
 charsets
  */
@@ -88,8 +88,8 @@ public class StringUtils {
  * @return A new {@code String} decoded from the specified array of bytes 
using the US-ASCII charset,
  * or {@code null} if the input byte array was {@code null}.
  * @throws NullPointerException
- * Thrown if {@link StandardCharsets#US_ASCII} is not 
initialized, which should never happen since it is
- * required by the Java platform specification.
+ * Thrown if {@link StandardCharsets#US_ASCII} is not 
initialized, which should never happen
+ * since it is required by the Java platform specification.
  * @since As of 1.7, throws {@link NullPointerException} instead of 
UnsupportedEncodingException
  */
 public static 

[tomcat] branch master updated: Update codec

2019-08-01 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new 0b3fba2  Update codec
0b3fba2 is described below

commit 0b3fba289ad2d62efec5d7d3cae65d468d044912
Author: Mark Thomas 
AuthorDate: Thu Aug 1 20:54:34 2019 +0100

Update codec
---
 MERGE.txt  |  2 +-
 .../apache/tomcat/util/codec/binary/Base64.java| 22 +-
 webapps/docs/changelog.xml |  4 
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index 267c7a5..a0e5a1c 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -43,7 +43,7 @@ Codec
 Sub-tree:
 src/main/java/org/apache/commons/codec
 The SHA1 ID for the most recent commit to be merged to Tomcat is:
-8502e2f14a6eafb0afa0964b34d1d1bb02b44f64 (2019-04-23)
+3ebef4ad92e31697fb52ca7cc71904c68654c2c8 (2019-08-01)
 Note: Only classes required for Base64 encoding/decoding. The rest are removed.
 
 FileUpload
diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
index ed13cb5..99a501c 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -421,7 +421,7 @@ public class Base64 extends BaseNCodec {
  * @param inPos
  *Position to start reading data from.
  * @param inAvail
- *Amount of bytes available from input for encoding.
+ *Amount of bytes available from input for decoding.
  * @param context
  *the context to be used
  */
@@ -469,10 +469,12 @@ public class Base64 extends BaseNCodec {
 // TODO not currently tested; perhaps it is impossible?
 break;
 case 2 : // 12 bits = 8 + 4
+validateCharacter(4, context);
 context.ibitWorkArea = context.ibitWorkArea >> 4; // dump 
the extra 4 bits
 buffer[context.pos++] = (byte) ((context.ibitWorkArea) & 
MASK_8BITS);
 break;
 case 3 : // 18 bits = 8 + 8 + 2
+validateCharacter(2, context);
 context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 
2 bits
 buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 
8) & MASK_8BITS);
 buffer[context.pos++] = (byte) ((context.ibitWorkArea) & 
MASK_8BITS);
@@ -770,4 +772,22 @@ public class Base64 extends BaseNCodec {
 return octet >= 0 && octet < decodeTable.length && decodeTable[octet] 
!= -1;
 }
 
+
+/**
+ * 
+ * Validates whether the character is possible in the context of the set 
of possible base 64 values.
+ * 
+ *
+ * @param numBitsToDrop number of least significant bits to check
+ * @param context the context to be used
+ *
+ * @throws IllegalArgumentException if the bits being checked contain any 
non-zero value
+ */
+private long validateCharacter(final int numBitsToDrop, final Context 
context) {
+if ((context.ibitWorkArea & numBitsToDrop) != 0) {
+throw new IllegalArgumentException(
+"Last encoded character (before the paddings if any) is a valid 
base 64 alphabet but not a possible value");
+}
+return context.ibitWorkArea >> numBitsToDrop;
+}
 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e351748..e515188 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -213,6 +213,10 @@
   
 Update dependency on bnd to 4.2.0. (markt)
   
+  
+Update the internal fork of Commons Codec to 3ebef4a (2018-08-01) to
+pick up the fix for CODEC-134. (markt)
+  
 
   
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org