THRIFT-3276 Binary data does not decode correctly using the TJSONProtocol when the base64 encoded data is padded.
This closes #645
diff --git a/lib/csharp/src/Protocol/TJSONProtocol.cs b/lib/csharp/src/Protocol/TJSONProtocol.cs
index 2e8d99f..4081d6e 100644
--- a/lib/csharp/src/Protocol/TJSONProtocol.cs
+++ b/lib/csharp/src/Protocol/TJSONProtocol.cs
@@ -544,6 +544,11 @@
int len = b.Length;
int off = 0;
+ // Ignore padding
+ int bound = len >= 2 ? len - 2 : 0;
+ for (int i = len - 1; i >= bound && b[i] == '='; --i) {
+ --len;
+ }
while (len >= 3)
{
// Encode 3 bytes at a time