Skip to content

Commit b4c7653

Browse files
committed
Base validation on standard table length
1 parent a22ddc3 commit b4c7653

File tree

1 file changed

+1
-4
lines changed
  • src/main/java/org/apache/commons/codec/binary

1 file changed

+1
-4
lines changed

src/main/java/org/apache/commons/codec/binary/Base64.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public Builder setUrlSafe(final boolean urlSafe) {
108108
private static final int BITS_PER_ENCODED_BYTE = 6;
109109
private static final int BYTES_PER_UNENCODED_BLOCK = 3;
110110
private static final int BYTES_PER_ENCODED_BLOCK = 4;
111-
private static final int ALPHABET_LENGTH = 64;
112111
private static final int DECODING_TABLE_LENGTH = 256;
113112

114113
/**
@@ -126,8 +125,6 @@ public Builder setUrlSafe(final boolean urlSafe) {
126125
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
127126
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
128127
};
129-
// @formatter:on
130-
131128
/**
132129
* This is a copy of the STANDARD_ENCODE_TABLE above, but with + and / changed to - and _ to make the encoded Base64 results more URL-SAFE. This table is
133130
* only used when the Base64's mode is set to URL-SAFE.
@@ -667,7 +664,7 @@ public Base64(final int lineLength, final byte[] lineSeparator, final boolean ur
667664
private Base64(final int lineLength, final byte[] lineSeparator, final byte padding, final byte[] encodeTable, final CodecPolicy decodingPolicy) {
668665
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, toLength(lineSeparator), padding, decodingPolicy);
669666
Objects.requireNonNull(encodeTable, "encodeTable");
670-
if (encodeTable.length != ALPHABET_LENGTH) {
667+
if (encodeTable.length != STANDARD_ENCODE_TABLE.length) {
671668
throw new IllegalArgumentException("encodeTable must have exactly 64 entries.");
672669
}
673670
this.isUrlSafe = encodeTable == URL_SAFE_ENCODE_TABLE;

0 commit comments

Comments
 (0)