File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
main/java/com/google/api/client/util
test/java/com/google/api/client/util Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ public static byte[] decodeBase64(String base64String) {
105
105
return null ;
106
106
}
107
107
108
+ base64String = base64String .replace ("\r " , "" );
109
+ base64String = base64String .replace ("\n " , "" );
110
+
108
111
try {
109
112
return BaseEncoding .base64 ().decode (base64String );
110
113
} catch (IllegalArgumentException e ) {
Original file line number Diff line number Diff line change 13
13
*/
14
14
package com .google .api .client .util ;
15
15
16
+ import java .util .Arrays ;
16
17
import junit .framework .TestCase ;
17
18
18
19
/**
@@ -54,4 +55,10 @@ public void testDecode() {
54
55
String value = new String (Base64 .decodeBase64 (Base64 .encodeBase64 ("foobar" .getBytes ())));
55
56
assertEquals ("foobar" , value );
56
57
}
58
+
59
+ public void testDecodeStripsCarriageReturnsAndNewlines () {
60
+ byte [] actual = Base64 .decodeBase64 ("aGVsbG8gd29ybGQ=\r \n " );
61
+ byte [] expected = "hello world" .getBytes ();
62
+ assertTrue (Arrays .equals (actual , expected ));
63
+ }
57
64
}
You can’t perform that action at this time.
0 commit comments