Skip to content

Commit 5b74e6d

Browse files
committed
Test truncated padding
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@670118 13f79535-47bb-0310-9956-ffa450edef68
1 parent 98a85c3 commit 5b74e6d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/test/org/apache/commons/codec/binary/Base64Test.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,21 @@ public void testDecodePadMarkerIndex3() {
7373
public void testDecodePadOnly() {
7474
assertTrue(Base64.decodeBase64("====".getBytes()).length == 0);
7575
assertEquals("", new String(Base64.decodeBase64("====".getBytes())));
76+
// Test truncated padding
77+
assertTrue(Base64.decodeBase64("===".getBytes()).length == 0);
78+
assertTrue(Base64.decodeBase64("==".getBytes()).length == 0);
79+
assertTrue(Base64.decodeBase64("=".getBytes()).length == 0);
80+
assertTrue(Base64.decodeBase64("".getBytes()).length == 0);
7681
}
7782

7883
public void testDecodePadOnlyChunked() {
7984
assertTrue(Base64.decodeBase64("====\n".getBytes()).length == 0);
8085
assertEquals("", new String(Base64.decodeBase64("====\n".getBytes())));
86+
// Test truncated padding
87+
assertTrue(Base64.decodeBase64("===\n".getBytes()).length == 0);
88+
assertTrue(Base64.decodeBase64("==\n".getBytes()).length == 0);
89+
assertTrue(Base64.decodeBase64("=\n".getBytes()).length == 0);
90+
assertTrue(Base64.decodeBase64("\n".getBytes()).length == 0);
8191
}
8292

8393
// encode/decode random arrays from size 0 to size 11

0 commit comments

Comments
 (0)