Skip to content

Commit 7fb904f

Browse files
committed
CODEC-170 Base32 decode table has spurious value
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1488493 13f79535-47bb-0310-9956-ffa450edef68
1 parent 21a8423 commit 7fb904f

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The <action> type attribute can be add,update,fix,remove.
4343
</properties>
4444
<body>
4545
<release version="1.9" date="TBA" description="Feature and fix release.">
46+
<action dev="sebb" type="fix" issue="CODEC-170" due-to="Matt Bishop">Base32 decode table has spurious value</action>
4647
<action dev="ggregory" type="fix" issue="CODEC-170" due-to="Ron Wheeler, Henri Yandell">Link broken in Metaphone Javadoc</action>
4748
</release>
4849
<release version="1.8" date="19 April 2013" description="Feature and fix release. Requires a minimum of Java 1.6">

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ public class Base32 extends BaseNCodec {
6161

6262
/**
6363
* This array is a lookup table that translates Unicode characters drawn from the "Base32 Alphabet" (as specified
64-
* in Table 3 of RFC 2045) into their 5-bit positive integer equivalents. Characters that are not in the Base32
64+
* in Table 3 of RFC 4648) into their 5-bit positive integer equivalents. Characters that are not in the Base32
6565
* alphabet but fall within the bounds of the array are translated to -1.
6666
*/
6767
private static final byte[] DECODE_TABLE = {
6868
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
6969
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f
7070
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f
71-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 63, // 20-2f
71+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20-2f
7272
-1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, // 30-3f 2-7
7373
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4f A-N
7474
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // 50-5a O-Z
7575
};
7676

7777
/**
7878
* This array is a lookup table that translates 5-bit positive integer index values into their "Base32 Alphabet"
79-
* equivalents as specified in Table 3 of RFC 2045.
79+
* equivalents as specified in Table 3 of RFC 4648.
8080
*/
8181
private static final byte[] ENCODE_TABLE = {
8282
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
@@ -86,22 +86,22 @@ public class Base32 extends BaseNCodec {
8686

8787
/**
8888
* This array is a lookup table that translates Unicode characters drawn from the "Base32 |Hex Alphabet" (as
89-
* specified in Table 3 of RFC 2045) into their 5-bit positive integer equivalents. Characters that are not in the
89+
* specified in Table 3 of RFC 4648) into their 5-bit positive integer equivalents. Characters that are not in the
9090
* Base32 Hex alphabet but fall within the bounds of the array are translated to -1.
9191
*/
9292
private static final byte[] HEX_DECODE_TABLE = {
9393
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
9494
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f
9595
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f
96-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 63, // 20-2f
96+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20-2f
9797
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, // 30-3f 2-7
9898
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 40-4f A-N
9999
25, 26, 27, 28, 29, 30, 31, 32, // 50-57 O-V
100100
};
101101

102102
/**
103103
* This array is a lookup table that translates 5-bit positive integer index values into their
104-
* "Base32 Hex Alphabet" equivalents as specified in Table 3 of RFC 2045.
104+
* "Base32 Hex Alphabet" equivalents as specified in Table 3 of RFC 4648.
105105
*/
106106
private static final byte[] HEX_ENCODE_TABLE = {
107107
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',

0 commit comments

Comments
 (0)