From f437b67f600545f432863457a39870cb74675d34 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 15 Jan 2016 12:02:07 +0000 Subject: Extra strictness for FieldMask conversion --- csharp/src/Google.Protobuf/JsonParser.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'csharp/src/Google.Protobuf/JsonParser.cs') diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index db601c57..9e5d8711 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -894,6 +894,8 @@ namespace Google.Protobuf private static string ToSnakeCase(string text) { var builder = new StringBuilder(text.Length * 2); + // Note: this is probably unnecessary now, but currently retained to be as close as possible to the + // C++, whilst still throwing an exception on underscores. bool wasNotUnderscore = false; // Initialize to false for case 1 (below) bool wasNotCap = false; @@ -927,7 +929,11 @@ namespace Google.Protobuf else { builder.Append(c); - wasNotUnderscore = c != '_'; + if (c == '_') + { + throw new InvalidProtocolBufferException($"Invalid field mask: {text}"); + } + wasNotUnderscore = true; wasNotCap = true; } } -- cgit v1.2.3