diff options
author | Jon Skeet <jonskeet@google.com> | 2016-01-15 10:55:36 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2016-01-15 10:55:36 +0000 |
commit | 888e71bdfc4918dbc16b62788c808cf415b7a8b0 (patch) | |
tree | 518e089494f329415402fbe44aee814c32daa8d0 /csharp/src/Google.Protobuf/JsonParser.cs | |
parent | 1a34ac03bed31434caa110acc25537d871966f9d (diff) | |
download | protobuf-888e71bdfc4918dbc16b62788c808cf415b7a8b0.tar.gz protobuf-888e71bdfc4918dbc16b62788c808cf415b7a8b0.tar.bz2 protobuf-888e71bdfc4918dbc16b62788c808cf415b7a8b0.zip |
Prohibit null values in repeated and map fields in JSON
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonParser.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/JsonParser.cs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index 10b05362..0d997a0a 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -239,6 +239,10 @@ namespace Google.Protobuf return; } tokenizer.PushBack(token); + if (token.Type == JsonToken.TokenType.Null) + { + throw new InvalidProtocolBufferException("Repeated field elements cannot be null"); + } list.Add(ParseSingleValue(field, tokenizer)); } } @@ -270,7 +274,10 @@ namespace Google.Protobuf } object key = ParseMapKey(keyField, token.StringValue); object value = ParseSingleValue(valueField, tokenizer); - // TODO: Null handling + if (value == null) + { + throw new InvalidProtocolBufferException("Map values must not be null"); + } dictionary[key] = value; } } |