Permalink
Browse files

Remove CR/LF characters from Base64 userdata string

Some Base64 implementations delimit encoded data with newlines.
Unfortunately, the isBase64 function of Globus does not support them.
Remove them prior to calling this function.

Closes #110.
  • Loading branch information...
1 parent 0b2be86 commit 621b9bb3dc1c31f2dae57a46c0f90d566384bfb1 @priteau priteau committed Aug 1, 2012
@@ -196,11 +196,14 @@ public CreateRequest translateRunInstances(RunInstancesType req,
if (t_userData != null) {
final String base64Encoded = t_userData.getData();
if (base64Encoded != null) {
- if (!Base64.isBase64(base64Encoded)) {
+ // Remove newlines from the base64 string since they are not
+ // supported by the Globus implementation
+ final String base64EncodedNoCRLF = base64Encoded.replaceAll("[\r\n]", "");
+ if (!Base64.isBase64(base64EncodedNoCRLF)) {
throw new RemoteException("userdata does not appear to " +
"be base64 encoded?");
}
- final byte[] bytes = Base64.decode(base64Encoded.getBytes());
+ final byte[] bytes = Base64.decode(base64EncodedNoCRLF.getBytes());
userData = new String(bytes);
}
}

0 comments on commit 621b9bb

Please sign in to comment.