commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherb...@apache.org
Subject [commons-codec] 01/05: [CODEC-270] Add more impossible base32/64 test cases.
Date Thu, 28 Nov 2019 10:50:36 GMT
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit 7b1961506509391ec847bb1dc3783a87f8069057
Author: Alex Herbert <aherbert@apache.org>
AuthorDate: Sun Nov 24 23:08:14 2019 +0000

    [CODEC-270] Add more impossible base32/64 test cases.
    
    These currently are parsed by the code as valid but should not be.
    
    Fixed the BCodec test impossible cases to contain the correct RFC 1522
    header.
---
 src/test/java/org/apache/commons/codec/binary/Base32Test.java |  3 ++-
 src/test/java/org/apache/commons/codec/binary/Base64Test.java |  1 +
 src/test/java/org/apache/commons/codec/net/BCodecTest.java    | 10 ++++++----
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/binary/Base32Test.java b/src/test/java/org/apache/commons/codec/binary/Base32Test.java
index d7d2d34..725b912 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base32Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base32Test.java
@@ -51,7 +51,8 @@ public class Base32Test {
         "MZXE====",
         "MZXWB===",
         "MZXW6YB=",
-        "MZXW6YTBOC======"
+        "MZXW6YTBOC======",
+        "AB======"
         };
 
     private static final String[] BASE32_IMPOSSIBLE_CASES_CHUNKED = {
diff --git a/src/test/java/org/apache/commons/codec/binary/Base64Test.java b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
index a9b9867..442fc4c 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
@@ -49,6 +49,7 @@ public class Base64Test {
         "ZmC=",
         "Zm9vYE==",
         "Zm9vYmC=",
+        "AB",
     };
 
     private final Random random = new Random();
diff --git a/src/test/java/org/apache/commons/codec/net/BCodecTest.java b/src/test/java/org/apache/commons/codec/net/BCodecTest.java
index 5a90629..2e23d5a 100644
--- a/src/test/java/org/apache/commons/codec/net/BCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/BCodecTest.java
@@ -34,10 +34,12 @@ import org.junit.Test;
  */
 public class BCodecTest {
     private static final String[] BASE64_IMPOSSIBLE_CASES = {
-            "ZE==",
-            "ZmC=",
-            "Zm9vYE==",
-            "Zm9vYmC=",
+            // Require the RFC 1522 "encoded-word" header
+            "=?ASCII?B?ZE==?=",
+            "=?ASCII?B?ZmC=?=",
+            "=?ASCII?B?Zm9vYE==?=",
+            "=?ASCII?B?Zm9vYmC=?=",
+            "=?ASCII?B?AB==?="
     };
 
     static final int SWISS_GERMAN_STUFF_UNICODE[] =


Mime
View raw message