From 1a34ac03bed31434caa110acc25537d871966f9d Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 15 Jan 2016 10:43:06 +0000 Subject: Throw a better exception when invalid base64 is detected in JSON --- csharp/src/Google.Protobuf.Test/JsonParserTest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'csharp/src/Google.Protobuf.Test') diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index b8fe67f8..b12fe895 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -821,6 +821,15 @@ namespace Google.Protobuf Assert.Throws(() => parser63.Parse(data64)); } + [Test] + [TestCase("AQI")] + [TestCase("_-==")] + public void Bytes_InvalidBase64(string badBase64) + { + string json = "{ \"singleBytes\": \"" + badBase64 + "\" }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + [Test] [TestCase("\"FOREIGN_BAR\"")] [TestCase("5")] -- cgit v1.2.3