Fix empty FieldMask json encoding/decoding (#5605)
* Fix empty FieldMask json encoding/decoding * Add failed test to python's conformance failure list
This commit is contained in:
parent
1069565a68
commit
7f42d6d0bc
@ -2042,6 +2042,10 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
|
||||
"FieldMask", REQUIRED,
|
||||
R"({"optionalFieldMask": "foo,barBaz"})",
|
||||
R"(optional_field_mask: {paths: "foo" paths: "bar_baz"})");
|
||||
RunValidJsonTest(
|
||||
"EmptyFieldMask", REQUIRED,
|
||||
R"({"optionalFieldMask": ""})",
|
||||
R"(optional_field_mask: {})");
|
||||
ExpectParseFailureForJson(
|
||||
"FieldMaskInvalidCharacter", RECOMMENDED,
|
||||
R"({"optionalFieldMask": "foo,bar_bar"})");
|
||||
|
@ -19,3 +19,4 @@ Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_0
|
||||
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_1
|
||||
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_2
|
||||
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_3
|
||||
Required.Proto3.JsonInput.EmptyFieldMask.ProtobufOutput
|
||||
|
@ -20,3 +20,4 @@ Required.Proto3.JsonInput.FloatFieldTooLarge
|
||||
Required.Proto3.JsonInput.FloatFieldTooSmall
|
||||
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||
Required.Proto3.JsonInput.TimestampJsonInputLowercaseT
|
||||
Required.Proto3.JsonInput.EmptyFieldMask.ProtobufOutput
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -518,8 +518,11 @@ class GPBUtil
|
||||
|
||||
public static function parseFieldMask($paths_string)
|
||||
{
|
||||
$path_strings = explode(",", $paths_string);
|
||||
$field_mask = new FieldMask();
|
||||
if (strlen($paths_string) === 0) {
|
||||
return $field_mask;
|
||||
}
|
||||
$path_strings = explode(",", $paths_string);
|
||||
$paths = $field_mask->getPaths();
|
||||
foreach($path_strings as &$path_string) {
|
||||
$field_strings = explode(".", $path_string);
|
||||
|
@ -1128,4 +1128,11 @@ class EncodeDecodeTest extends TestBase
|
||||
$this->assertSame("\"foo.barBaz,qux\"", $m->serializeToJsonString());
|
||||
}
|
||||
|
||||
public function testDecodeEmptyFieldMask()
|
||||
{
|
||||
$m = new FieldMask();
|
||||
$m->mergeFromJsonString("\"\"");
|
||||
$this->assertEquals("", $m->serializeToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user