diff options
author | Jon Skeet <jonskeet@google.com> | 2016-01-15 12:02:07 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2016-01-15 12:02:07 +0000 |
commit | f437b67f600545f432863457a39870cb74675d34 (patch) | |
tree | 608f813163899f678c04726117f36a006199b332 /csharp/src/Google.Protobuf/JsonParser.cs | |
parent | 022a9b267561a3fccfcfaa7023779b969692bf74 (diff) | |
download | protobuf-f437b67f600545f432863457a39870cb74675d34.tar.gz protobuf-f437b67f600545f432863457a39870cb74675d34.tar.bz2 protobuf-f437b67f600545f432863457a39870cb74675d34.zip |
Extra strictness for FieldMask conversion
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonParser.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/JsonParser.cs | 8 |
1 files changed, 7 insertions, 1 deletions
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; } } |