groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/3] groovy git commit: GROOVY-8357: EncodingGroovyMethods.decodeBase64() throws "bad character in base64 value" when meets \t \r (closes #623)
Date Wed, 01 Nov 2017 09:07:10 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X fb8e7d5c7 -> b45e36aac


GROOVY-8357: EncodingGroovyMethods.decodeBase64() throws "bad character in base64 value" when
meets \t \r (closes #623)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5b1a6013
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5b1a6013
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5b1a6013

Branch: refs/heads/GROOVY_2_6_X
Commit: 5b1a6013e62c6b5d77beda118093c5564dc6a603
Parents: 0114f77
Author: paulk <paulk@asert.com.au>
Authored: Mon Oct 30 12:37:05 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Wed Nov 1 19:06:52 2017 +1000

----------------------------------------------------------------------
 .../runtime/EncodingGroovyMethodsSupport.java   | 58 ++++++++++----------
 src/test/groovy/Base64Test.groovy               |  3 +
 2 files changed, 32 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5b1a6013/src/main/org/codehaus/groovy/runtime/EncodingGroovyMethodsSupport.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/EncodingGroovyMethodsSupport.java b/src/main/org/codehaus/groovy/runtime/EncodingGroovyMethodsSupport.java
index ef134bd..24929a8 100644
--- a/src/main/org/codehaus/groovy/runtime/EncodingGroovyMethodsSupport.java
+++ b/src/main/org/codehaus/groovy/runtime/EncodingGroovyMethodsSupport.java
@@ -24,67 +24,67 @@ package org.codehaus.groovy.runtime;
 public class EncodingGroovyMethodsSupport {
     static final byte[] TRANSLATE_TABLE = (
             "\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
-                    //                    \t    \n                \r
-                    + "\u0042\u0042\u0041\u0041\u0042\u0042\u0041\u0042"
+                    //           \t    \n                \r
+                    + "\u0042\u0041\u0041\u0042\u0042\u0041\u0042\u0042"
                     //
                     + "\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
                     //
                     + "\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
-                    //        sp    !     "     #     $     %     &     '
+                    //     sp     !     "     #     $     %     &     '
                     + "\u0041\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
-                    //         (    )     *     +     ,     -     .     /
+                    //      (     )     *     +     ,     -     .     /
                     + "\u0042\u0042\u0042\u003E\u0042\u0042\u0042\u003F"
-                    //         0    1     2     3     4     5     6     7
+                    //      0     1     2     3     4     5     6     7
                     + "\u0034\u0035\u0036\u0037\u0038\u0039\u003A\u003B"
-                    //         8    9     :     ;     <     =     >     ?
+                    //      8     9     :     ;     <     =     >     ?
                     + "\u003C\u003D\u0042\u0042\u0042\u0040\u0042\u0042"
-                    //         @    A     B     C     D     E     F     G
+                    //      @     A     B     C     D     E     F     G
                     + "\u0042\u0000\u0001\u0002\u0003\u0004\u0005\u0006"
-                    //         H    I   J K   L     M   N   O
+                    //      H     I J K     L     M N     O
                     + "\u0007\u0008\t\n\u000B\u000C\r\u000E"
-                    //         P    Q     R     S     T     U     V    W
+                    //      P     Q     R     S     T     U     V     W
                     + "\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016"
-                    //         X    Y     Z     [     \     ]     ^    _
+                    //      X     Y     Z     [     \     ]     ^     _
                     + "\u0017\u0018\u0019\u0042\u0042\u0042\u0042\u0042"
-                    //         '    a     b     c     d     e     f     g
+                    //      '     a     b     c     d     e     f     g
                     + "\u0042\u001A\u001B\u001C\u001D\u001E\u001F\u0020"
-                    //        h   i   j     k     l     m     n     o    p
+                    //      h i     j     k     l     m     n     o
                     + "\u0021\"\u0023\u0024\u0025\u0026\u0027\u0028"
-                    //        p     q     r     s     t     u     v     w
+                    //      p     q     r     s     t     u     v     w
                     + "\u0029\u002A\u002B\u002C\u002D\u002E\u002F\u0030"
-                    //        x     y     z
+                    //      x     y     z
                     + "\u0031\u0032\u0033").getBytes();
 
     static final byte[] TRANSLATE_TABLE_URLSAFE = (
             "\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
-                    //                    \t    \n                \r
-                    + "\u0042\u0042\u0041\u0041\u0042\u0042\u0041\u0042"
+                    //           \t    \n                \r
+                    + "\u0042\u0041\u0041\u0042\u0042\u0041\u0042\u0042"
                     //
                     + "\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
                     //
                     + "\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
-                    //        sp    !     "     #     $     %     &     '
+                    //     sp     !     "     #     $     %     &     '
                     + "\u0041\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
-                    //         (    )     *     +     ,     -     .     /
+                    //      (     )     *     +     ,     -     .     /
                     + "\u0042\u0042\u0042\u0042\u0042\u003E\u0042\u0042"
-                    //         0    1     2     3     4     5     6     7
+                    //      0     1     2     3     4     5     6     7
                     + "\u0034\u0035\u0036\u0037\u0038\u0039\u003A\u003B"
-                    //         8    9     :     ;     <     =     >     ?
+                    //      8     9     :     ;     <     =     >     ?
                     + "\u003C\u003D\u0042\u0042\u0042\u0040\u0042\u0042"
-                    //         @    A     B     C     D     E     F     G
+                    //      @     A     B     C     D     E     F     G
                     + "\u0042\u0000\u0001\u0002\u0003\u0004\u0005\u0006"
-                    //         H    I   J K   L     M   N   O
+                    //      H     I J K     L     M N     O
                     + "\u0007\u0008\t\n\u000B\u000C\r\u000E"
-                    //         P    Q     R     S     T     U     V    W
+                    //      P     Q     R     S     T     U     V     W
                     + "\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016"
-                    //         X    Y     Z     [     \     ]     ^    _
+                    //      X     Y     Z     [     \     ]     ^     _
                     + "\u0017\u0018\u0019\u0042\u0042\u0042\u0042\u003F"
-                    //         '    a     b     c     d     e     f     g
+                    //      '     a     b     c     d     e     f     g
                     + "\u0042\u001A\u001B\u001C\u001D\u001E\u001F\u0020"
-                    //        h   i   j     k     l     m     n     o    p
+                    //      h i     j     k     l     m     n     o
                     + "\u0021\"\u0023\u0024\u0025\u0026\u0027\u0028"
-                    //        p     q     r     s     t     u     v     w
+                    //      p     q     r     s     t     u     v     w
                     + "\u0029\u002A\u002B\u002C\u002D\u002E\u002F\u0030"
-                    //        x     y     z
+                    //      x     y     z
                     + "\u0031\u0032\u0033").getBytes();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/5b1a6013/src/test/groovy/Base64Test.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/Base64Test.groovy b/src/test/groovy/Base64Test.groovy
index 2f23bba..0904f86 100644
--- a/src/test/groovy/Base64Test.groovy
+++ b/src/test/groovy/Base64Test.groovy
@@ -61,6 +61,9 @@ class Base64Test extends GroovyTestCase {
         assert line0.size() == 76
         assert line0 == 'pzEyMzQ1Njc4OTAtPbEhQKMkJV4mKigpXytxd2VydHl1aW9wW11RV0VSVFlVSU9Qe31hc2RmZ2hq'
         assert line1 == 'a2w7J1xBU0RGR0hKS0w6InxgenhjdmJubSwuL35aWENWQk5NPD4/A//wDw=='
+        // check we allow \n \r \t and space to be ignored when decoding for round-tripping
purposes
+        assert encodedBytes.decodeBase64() == testBytes
+        assert (encodedBytes + '\t ').decodeBase64() == testBytes
     }
 
     void testNonChunked() {


Mime
View raw message