blob: 14ab0f1f179241febf2eea8d1a44f51088945d56 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
--- a/src/google/protobuf/json/internal/parser.cc
+++ b/src/google/protobuf/json/internal/parser.cc
@@ -972,13 +972,29 @@
// Assume approximately six-letter words, so add one extra space for an
// underscore for every six bytes.
snake_path.reserve(path.size() * 7 / 6);
+ // Port from protobuf 21.x
+ bool is_quoted = false;
+ bool is_escaping = false;
for (char c : path) {
+ // Outputs quoted string as-is.
+ if (is_quoted) {
+ snake_path.push_back(c);
+ if (is_escaping) {
+ is_escaping = false;
+ } else if (c == '\\') {
+ is_escaping = true;
+ } else if (c == '\"') {
+ is_quoted = false;
+ }
+ continue;
+ }
if (absl::ascii_isdigit(c) || absl::ascii_islower(c) || c == '.') {
snake_path.push_back(c);
} else if (absl::ascii_isupper(c)) {
snake_path.push_back('_');
snake_path.push_back(absl::ascii_tolower(c));
} else if (lex.options().allow_legacy_syntax) {
+ is_quoted = c == '\"';
snake_path.push_back(c);
} else {
return str->loc.Invalid("unexpected character in FieldMask");
@@ -1314,6 +1330,9 @@
s = absl::InvalidArgumentError(
"extraneous characters after end of JSON object");
}
+ if (s.ok() && !message->IsInitialized()) {
+ s = absl::InvalidArgumentError("Not all fileds are sets");
+ }
PROTOBUF_DLOG(INFO) << "json2/status: " << s;
PROTOBUF_DLOG(INFO) << "json2/output: " << message->DebugString();
|