aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/JsonParser.cs
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2016-01-15 10:43:06 +0000
committerGravatar Jon Skeet <jonskeet@google.com>2016-01-15 10:43:06 +0000
commit1a34ac03bed31434caa110acc25537d871966f9d (patch)
tree86da369b3748d9efff3afd90f6090b42ff93f8c0 /csharp/src/Google.Protobuf/JsonParser.cs
parent730c38ad8c11429bc7ea0310bc1b82f0831b42a6 (diff)
Throw a better exception when invalid base64 is detected in JSON
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonParser.cs')
-rw-r--r--csharp/src/Google.Protobuf/JsonParser.cs9
1 files changed, 8 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs
index 25afd0f2..10b05362 100644
--- a/csharp/src/Google.Protobuf/JsonParser.cs
+++ b/csharp/src/Google.Protobuf/JsonParser.cs
@@ -647,7 +647,14 @@ namespace Google.Protobuf
case FieldType.String:
return text;
case FieldType.Bytes:
- return ByteString.FromBase64(text);
+ try
+ {
+ return ByteString.FromBase64(text);
+ }
+ catch (FormatException e)
+ {
+ throw InvalidProtocolBufferException.InvalidBase64(e);
+ }
case FieldType.Int32:
case FieldType.SInt32:
case FieldType.SFixed32: