-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Open
Description
What version of protobuf and what language are you using?
Version: main
Language: Java
What operating system (Linux, Windows, ...) and version?
Linux
What did you do?
I have a proto like this:
message AuditFields {
.google.protobuf.FieldMask field_mask = 1;
repeated .google.protobuf.FieldMask field_mask_r = 2;
repeated string string_r = 3;
}
Now I have this Java code:
AuditFields.Builder fields =
AuditFields.newBuilder()
.setFieldMask(FieldMask.newBuilder().addPaths("\"").build())
.addStringR("\"")
.addFieldMaskR(FieldMask.newBuilder().addPaths("\"").build());
System.out.println("fields: " + JsonFormat.printer().print(fields));
Which prints:
fields: {
"stringR": ["\""],
"fieldMask": """,
"fieldMaskR": ["""]
}
The quote is properly escaped in the repeated string field but NOT properly escaped in the repeated Field mask.
I think the bug has something to do with FieldMask having a special encoding: https://protobuf.dev/reference/protobuf/google.protobuf/#json-encoding-field-masks