diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index bdc3691239..45d9c1678d 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -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"})"); diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt index e3ce7af759..ce7cdec29a 100644 --- a/conformance/failure_list_python.txt +++ b/conformance/failure_list_python.txt @@ -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 diff --git a/conformance/failure_list_python_cpp.txt b/conformance/failure_list_python_cpp.txt index 59a969d2f5..45319464a1 100644 --- a/conformance/failure_list_python_cpp.txt +++ b/conformance/failure_list_python_cpp.txt @@ -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 diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index a2634ce493..8452334ddf 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -15151,6 +15151,210 @@ static const char _json_actions[] = { 23, 24, 4, 14, 15, 16, 17 }; +static const short _json_key_offsets[] = { + 0, 0, 12, 13, 18, 23, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, + 38, 43, 44, 48, 53, 58, 63, 67, + 71, 74, 77, 79, 83, 87, 89, 91, + 96, 98, 100, 109, 115, 121, 127, 133, + 135, 139, 142, 144, 146, 149, 150, 154, + 156, 158, 160, 162, 163, 165, 167, 168, + 170, 172, 173, 175, 177, 178, 180, 182, + 183, 185, 187, 191, 193, 195, 196, 197, + 198, 199, 201, 206, 208, 210, 212, 221, + 222, 222, 222, 227, 232, 237, 238, 239, + 240, 241, 241, 242, 243, 244, 244, 245, + 246, 247, 247, 252, 253, 257, 262, 267, + 272, 276, 276, 279, 282, 285, 288, 291, + 294, 294, 294, 294, 294, 294 +}; + +static const char _json_trans_keys[] = { + 32, 34, 45, 91, 102, 110, 116, 123, + 9, 13, 48, 57, 34, 32, 93, 125, + 9, 13, 32, 44, 93, 9, 13, 32, + 93, 125, 9, 13, 97, 108, 115, 101, + 117, 108, 108, 114, 117, 101, 32, 34, + 125, 9, 13, 34, 32, 58, 9, 13, + 32, 93, 125, 9, 13, 32, 44, 125, + 9, 13, 32, 44, 125, 9, 13, 32, + 34, 9, 13, 45, 48, 49, 57, 48, + 49, 57, 46, 69, 101, 48, 57, 69, + 101, 48, 57, 43, 45, 48, 57, 48, + 57, 48, 57, 46, 69, 101, 48, 57, + 34, 92, 34, 92, 34, 47, 92, 98, + 102, 110, 114, 116, 117, 48, 57, 65, + 70, 97, 102, 48, 57, 65, 70, 97, + 102, 48, 57, 65, 70, 97, 102, 48, + 57, 65, 70, 97, 102, 34, 92, 45, + 48, 49, 57, 48, 49, 57, 46, 115, + 48, 57, 115, 48, 57, 34, 46, 115, + 48, 57, 48, 57, 48, 57, 48, 57, + 48, 57, 45, 48, 57, 48, 57, 45, + 48, 57, 48, 57, 84, 48, 57, 48, + 57, 58, 48, 57, 48, 57, 58, 48, + 57, 48, 57, 43, 45, 46, 90, 48, + 57, 48, 57, 58, 48, 48, 34, 48, + 57, 43, 45, 90, 48, 57, 34, 44, + 34, 44, 34, 44, 34, 45, 91, 102, + 110, 116, 123, 48, 57, 34, 32, 93, + 125, 9, 13, 32, 44, 93, 9, 13, + 32, 93, 125, 9, 13, 97, 108, 115, + 101, 117, 108, 108, 114, 117, 101, 32, + 34, 125, 9, 13, 34, 32, 58, 9, + 13, 32, 93, 125, 9, 13, 32, 44, + 125, 9, 13, 32, 44, 125, 9, 13, + 32, 34, 9, 13, 32, 9, 13, 32, + 9, 13, 32, 9, 13, 32, 9, 13, + 32, 9, 13, 32, 9, 13, 0 +}; + +static const char _json_single_lengths[] = { + 0, 8, 1, 3, 3, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 3, 1, 2, 3, 3, 3, 2, 2, + 1, 3, 0, 2, 2, 0, 0, 3, + 2, 2, 9, 0, 0, 0, 0, 2, + 2, 1, 2, 0, 1, 1, 2, 0, + 0, 0, 0, 1, 0, 0, 1, 0, + 0, 1, 0, 0, 1, 0, 0, 1, + 0, 0, 4, 0, 0, 1, 1, 1, + 1, 0, 3, 2, 2, 2, 7, 1, + 0, 0, 3, 3, 3, 1, 1, 1, + 1, 0, 1, 1, 1, 0, 1, 1, + 1, 0, 3, 1, 2, 3, 3, 3, + 2, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0 +}; + +static const char _json_range_lengths[] = { + 0, 2, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 1, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 3, 3, 3, 3, 0, + 1, 1, 0, 1, 1, 0, 1, 1, + 1, 1, 1, 0, 1, 1, 0, 1, + 1, 0, 1, 1, 0, 1, 1, 0, + 1, 1, 0, 1, 1, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 1, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0 +}; + +static const short _json_index_offsets[] = { + 0, 0, 11, 13, 18, 23, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, + 48, 53, 55, 59, 64, 69, 74, 78, + 82, 85, 89, 91, 95, 99, 101, 103, + 108, 111, 114, 124, 128, 132, 136, 140, + 143, 147, 150, 153, 155, 158, 160, 164, + 166, 168, 170, 172, 174, 176, 178, 180, + 182, 184, 186, 188, 190, 192, 194, 196, + 198, 200, 202, 207, 209, 211, 213, 215, + 217, 219, 221, 226, 229, 232, 235, 244, + 246, 247, 248, 253, 258, 263, 265, 267, + 269, 271, 272, 274, 276, 278, 279, 281, + 283, 285, 286, 291, 293, 297, 302, 307, + 312, 316, 317, 320, 323, 326, 329, 332, + 335, 336, 337, 338, 339, 340 +}; + +static const unsigned char _json_indicies[] = { + 0, 2, 3, 4, 5, 6, 7, 8, + 0, 3, 1, 9, 1, 11, 12, 1, + 11, 10, 13, 14, 12, 13, 1, 14, + 1, 1, 14, 10, 15, 1, 16, 1, + 17, 1, 18, 1, 19, 1, 20, 1, + 21, 1, 22, 1, 23, 1, 24, 1, + 25, 26, 27, 25, 1, 28, 1, 29, + 30, 29, 1, 30, 1, 1, 30, 31, + 32, 33, 34, 32, 1, 35, 36, 27, + 35, 1, 36, 26, 36, 1, 37, 38, + 39, 1, 38, 39, 1, 41, 42, 42, + 40, 43, 1, 42, 42, 43, 40, 44, + 44, 45, 1, 45, 1, 45, 40, 41, + 42, 42, 39, 40, 47, 48, 46, 50, + 51, 49, 52, 52, 52, 52, 52, 52, + 52, 52, 53, 1, 54, 54, 54, 1, + 55, 55, 55, 1, 56, 56, 56, 1, + 57, 57, 57, 1, 59, 60, 58, 61, + 62, 63, 1, 64, 65, 1, 66, 67, + 1, 68, 1, 67, 68, 1, 69, 1, + 66, 67, 65, 1, 70, 1, 71, 1, + 72, 1, 73, 1, 74, 1, 75, 1, + 76, 1, 77, 1, 78, 1, 79, 1, + 80, 1, 81, 1, 82, 1, 83, 1, + 84, 1, 85, 1, 86, 1, 87, 1, + 88, 1, 89, 89, 90, 91, 1, 92, + 1, 93, 1, 94, 1, 95, 1, 96, + 1, 97, 1, 98, 1, 99, 99, 100, + 98, 1, 102, 1, 101, 104, 105, 103, + 1, 1, 101, 106, 107, 108, 109, 110, + 111, 112, 107, 1, 113, 1, 114, 115, + 117, 118, 1, 117, 116, 119, 120, 118, + 119, 1, 120, 1, 1, 120, 116, 121, + 1, 122, 1, 123, 1, 124, 1, 125, + 126, 1, 127, 1, 128, 1, 129, 130, + 1, 131, 1, 132, 1, 133, 134, 135, + 136, 134, 1, 137, 1, 138, 139, 138, + 1, 139, 1, 1, 139, 140, 141, 142, + 143, 141, 1, 144, 145, 136, 144, 1, + 145, 135, 145, 1, 146, 147, 147, 1, + 148, 148, 1, 149, 149, 1, 150, 150, + 1, 151, 151, 1, 152, 152, 1, 1, + 1, 1, 1, 1, 1, 0 +}; + +static const char _json_trans_targs[] = { + 1, 0, 2, 107, 3, 6, 10, 13, + 16, 106, 4, 3, 106, 4, 5, 7, + 8, 9, 108, 11, 12, 109, 14, 15, + 110, 16, 17, 111, 18, 18, 19, 20, + 21, 22, 111, 21, 22, 24, 25, 31, + 112, 26, 28, 27, 29, 30, 33, 113, + 34, 33, 113, 34, 32, 35, 36, 37, + 38, 39, 33, 113, 34, 41, 42, 46, + 42, 46, 43, 45, 44, 114, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 73, 72, 68, 69, 70, 71, + 72, 115, 74, 67, 72, 76, 116, 76, + 116, 77, 79, 81, 82, 85, 90, 94, + 98, 80, 117, 117, 83, 82, 80, 83, + 84, 86, 87, 88, 89, 117, 91, 92, + 93, 117, 95, 96, 97, 117, 98, 99, + 105, 100, 100, 101, 102, 103, 104, 105, + 103, 104, 117, 106, 106, 106, 106, 106, + 106 +}; + +static const char _json_trans_actions[] = { + 0, 0, 92, 86, 35, 0, 0, 0, + 104, 41, 27, 0, 37, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 80, 33, 29, 0, 0, 27, + 31, 31, 83, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 5, 15, + 0, 0, 53, 7, 13, 0, 56, 9, + 9, 9, 59, 62, 11, 17, 17, 17, + 0, 0, 0, 19, 0, 21, 23, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 114, 65, 114, 0, 0, 0, 0, + 0, 71, 0, 68, 68, 77, 25, 0, + 110, 74, 92, 86, 35, 0, 0, 0, + 104, 41, 51, 89, 27, 0, 37, 0, + 0, 0, 0, 0, 0, 98, 0, 0, + 0, 101, 0, 0, 0, 95, 0, 80, + 33, 29, 0, 0, 27, 31, 31, 83, + 0, 0, 107, 0, 39, 45, 47, 43, + 49 +}; + static const char _json_eof_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -15203,883 +15407,83 @@ size_t parse(void *closure, const void *hd, const char *buf, size_t size, capture_resume(parser, buf); -#line 2627 "upb/json/parser.c" +#line 2831 "upb/json/parser.c" { + int _klen; + unsigned int _trans; const char *_acts; unsigned int _nacts; + const char *_keys; if ( p == pe ) goto _test_eof; if ( cs == 0 ) goto _out; _resume: - switch ( cs ) { -case 1: - switch( (*p) ) { - case 32: goto tr0; - case 34: goto tr2; - case 45: goto tr3; - case 91: goto tr4; - case 102: goto tr5; - case 110: goto tr6; - case 116: goto tr7; - case 123: goto tr8; - } - if ( (*p) > 13 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr3; - } else if ( (*p) >= 9 ) - goto tr0; - goto tr1; -case 0: - goto _out; -case 2: - if ( (*p) == 34 ) - goto tr9; - goto tr1; -case 106: - if ( (*p) == 32 ) - goto tr147; - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr147; - goto tr1; -case 107: - if ( (*p) == 32 ) - goto tr148; - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr148; - goto tr1; -case 3: - switch( (*p) ) { - case 32: goto tr11; - case 93: goto tr12; - case 125: goto tr1; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr11; - goto tr10; -case 4: - switch( (*p) ) { - case 32: goto tr13; - case 44: goto tr14; - case 93: goto tr12; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr13; - goto tr1; -case 5: - switch( (*p) ) { - case 32: goto tr14; - case 93: goto tr1; - case 125: goto tr1; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr14; - goto tr10; -case 6: - if ( (*p) == 97 ) - goto tr15; - goto tr1; -case 7: - if ( (*p) == 108 ) - goto tr16; - goto tr1; -case 8: - if ( (*p) == 115 ) - goto tr17; - goto tr1; -case 9: - if ( (*p) == 101 ) - goto tr18; - goto tr1; -case 108: - if ( (*p) == 32 ) - goto tr149; - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr149; - goto tr1; -case 10: - if ( (*p) == 117 ) - goto tr19; - goto tr1; -case 11: - if ( (*p) == 108 ) - goto tr20; - goto tr1; -case 12: - if ( (*p) == 108 ) - goto tr21; - goto tr1; -case 109: - if ( (*p) == 32 ) - goto tr150; - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr150; - goto tr1; -case 13: - if ( (*p) == 114 ) - goto tr22; - goto tr1; -case 14: - if ( (*p) == 117 ) - goto tr23; - goto tr1; -case 15: - if ( (*p) == 101 ) - goto tr24; - goto tr1; -case 110: - if ( (*p) == 32 ) - goto tr151; - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr151; - goto tr1; -case 16: - switch( (*p) ) { - case 32: goto tr25; - case 34: goto tr26; - case 125: goto tr27; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr25; - goto tr1; -case 17: - if ( (*p) == 34 ) - goto tr28; - goto tr1; -case 18: - switch( (*p) ) { - case 32: goto tr29; - case 58: goto tr30; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr29; - goto tr1; -case 19: - switch( (*p) ) { - case 32: goto tr30; - case 93: goto tr1; - case 125: goto tr1; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr30; - goto tr31; -case 20: - switch( (*p) ) { - case 32: goto tr32; - case 44: goto tr33; - case 125: goto tr34; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr32; - goto tr1; -case 21: - switch( (*p) ) { - case 32: goto tr35; - case 44: goto tr36; - case 125: goto tr27; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr35; - goto tr1; -case 22: - switch( (*p) ) { - case 32: goto tr36; - case 34: goto tr26; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr36; - goto tr1; -case 111: - if ( (*p) == 32 ) - goto tr152; - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr152; - goto tr1; -case 23: - switch( (*p) ) { - case 45: goto tr37; - case 48: goto tr38; - } - if ( 49 <= (*p) && (*p) <= 57 ) - goto tr39; - goto tr1; -case 24: - if ( (*p) == 48 ) - goto tr38; - if ( 49 <= (*p) && (*p) <= 57 ) - goto tr39; - goto tr1; -case 25: - switch( (*p) ) { - case 46: goto tr41; - case 69: goto tr42; - case 101: goto tr42; - } - goto tr40; -case 112: - goto tr1; -case 26: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr43; - goto tr1; -case 27: - switch( (*p) ) { - case 69: goto tr42; - case 101: goto tr42; - } - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr43; - goto tr40; -case 28: - switch( (*p) ) { - case 43: goto tr44; - case 45: goto tr44; - } - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr45; - goto tr1; -case 29: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr45; - goto tr1; -case 30: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr45; - goto tr40; -case 31: - switch( (*p) ) { - case 46: goto tr41; - case 69: goto tr42; - case 101: goto tr42; - } - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr39; - goto tr40; -case 32: - switch( (*p) ) { - case 34: goto tr47; - case 92: goto tr48; - } - goto tr46; -case 33: - switch( (*p) ) { - case 34: goto tr50; - case 92: goto tr51; - } - goto tr49; -case 113: - goto tr1; -case 34: - switch( (*p) ) { - case 34: goto tr52; - case 47: goto tr52; - case 92: goto tr52; - case 98: goto tr52; - case 102: goto tr52; - case 110: goto tr52; - case 114: goto tr52; - case 116: goto tr52; - case 117: goto tr53; - } - goto tr1; -case 35: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr54; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto tr54; - } else - goto tr54; - goto tr1; -case 36: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr55; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto tr55; - } else - goto tr55; - goto tr1; -case 37: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr56; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto tr56; - } else - goto tr56; - goto tr1; -case 38: - if ( (*p) < 65 ) { - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr57; - } else if ( (*p) > 70 ) { - if ( 97 <= (*p) && (*p) <= 102 ) - goto tr57; - } else - goto tr57; - goto tr1; -case 39: - switch( (*p) ) { - case 34: goto tr59; - case 92: goto tr60; - } - goto tr58; -case 40: - switch( (*p) ) { - case 45: goto tr61; - case 48: goto tr62; - } - if ( 49 <= (*p) && (*p) <= 57 ) - goto tr63; - goto tr1; -case 41: - if ( (*p) == 48 ) - goto tr64; - if ( 49 <= (*p) && (*p) <= 57 ) - goto tr65; - goto tr1; -case 42: - switch( (*p) ) { - case 46: goto tr66; - case 115: goto tr67; - } - goto tr1; -case 43: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr68; - goto tr1; -case 44: - if ( (*p) == 115 ) - goto tr67; - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr68; - goto tr1; -case 45: - if ( (*p) == 34 ) - goto tr69; - goto tr1; -case 114: - goto tr1; -case 46: - switch( (*p) ) { - case 46: goto tr66; - case 115: goto tr67; - } - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr65; - goto tr1; -case 47: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr70; - goto tr1; -case 48: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr71; - goto tr1; -case 49: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr72; - goto tr1; -case 50: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr73; - goto tr1; -case 51: - if ( (*p) == 45 ) - goto tr74; - goto tr1; -case 52: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr75; - goto tr1; -case 53: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr76; - goto tr1; -case 54: - if ( (*p) == 45 ) - goto tr77; - goto tr1; -case 55: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr78; - goto tr1; -case 56: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr79; - goto tr1; -case 57: - if ( (*p) == 84 ) - goto tr80; - goto tr1; -case 58: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr81; - goto tr1; -case 59: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr82; - goto tr1; -case 60: - if ( (*p) == 58 ) - goto tr83; - goto tr1; -case 61: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr84; - goto tr1; -case 62: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr85; - goto tr1; -case 63: - if ( (*p) == 58 ) - goto tr86; - goto tr1; -case 64: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr87; - goto tr1; -case 65: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr88; - goto tr1; -case 66: - switch( (*p) ) { - case 43: goto tr89; - case 45: goto tr89; - case 46: goto tr90; - case 90: goto tr91; - } - goto tr1; -case 67: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr92; - goto tr1; -case 68: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr93; - goto tr1; -case 69: - if ( (*p) == 58 ) - goto tr94; - goto tr1; -case 70: - if ( (*p) == 48 ) - goto tr95; - goto tr1; -case 71: - if ( (*p) == 48 ) - goto tr96; - goto tr1; -case 72: - if ( (*p) == 34 ) - goto tr97; - goto tr1; -case 115: - goto tr1; -case 73: - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr98; - goto tr1; -case 74: - switch( (*p) ) { - case 43: goto tr99; - case 45: goto tr99; - case 90: goto tr100; - } - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr98; - goto tr1; -case 75: - switch( (*p) ) { - case 34: goto tr102; - case 44: goto tr1; - } - goto tr101; -case 76: - switch( (*p) ) { - case 34: goto tr104; - case 44: goto tr105; - } - goto tr103; -case 116: - goto tr1; -case 77: - switch( (*p) ) { - case 34: goto tr1; - case 44: goto tr1; - } - goto tr101; -case 78: - switch( (*p) ) { - case 34: goto tr106; - case 45: goto tr107; - case 91: goto tr108; - case 102: goto tr109; - case 110: goto tr110; - case 116: goto tr111; - case 123: goto tr112; - } - if ( 48 <= (*p) && (*p) <= 57 ) - goto tr107; - goto tr1; -case 79: - if ( (*p) == 34 ) - goto tr113; - goto tr1; -case 80: - goto tr114; -case 117: - goto tr1; -case 81: - goto tr115; -case 82: - switch( (*p) ) { - case 32: goto tr117; - case 93: goto tr118; - case 125: goto tr1; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr117; - goto tr116; -case 83: - switch( (*p) ) { - case 32: goto tr119; - case 44: goto tr120; - case 93: goto tr118; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr119; - goto tr1; -case 84: - switch( (*p) ) { - case 32: goto tr120; - case 93: goto tr1; - case 125: goto tr1; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr120; - goto tr116; -case 85: - if ( (*p) == 97 ) - goto tr121; - goto tr1; -case 86: - if ( (*p) == 108 ) - goto tr122; - goto tr1; -case 87: - if ( (*p) == 115 ) - goto tr123; - goto tr1; -case 88: - if ( (*p) == 101 ) - goto tr124; - goto tr1; -case 89: - goto tr125; -case 90: - if ( (*p) == 117 ) - goto tr126; - goto tr1; -case 91: - if ( (*p) == 108 ) - goto tr127; - goto tr1; -case 92: - if ( (*p) == 108 ) - goto tr128; - goto tr1; -case 93: - goto tr129; -case 94: - if ( (*p) == 114 ) - goto tr130; - goto tr1; -case 95: - if ( (*p) == 117 ) - goto tr131; - goto tr1; -case 96: - if ( (*p) == 101 ) - goto tr132; - goto tr1; -case 97: - goto tr133; -case 98: - switch( (*p) ) { - case 32: goto tr134; - case 34: goto tr135; - case 125: goto tr136; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr134; - goto tr1; -case 99: - if ( (*p) == 34 ) - goto tr137; - goto tr1; -case 100: - switch( (*p) ) { - case 32: goto tr138; - case 58: goto tr139; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr138; - goto tr1; -case 101: - switch( (*p) ) { - case 32: goto tr139; - case 93: goto tr1; - case 125: goto tr1; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr139; - goto tr140; -case 102: - switch( (*p) ) { - case 32: goto tr141; - case 44: goto tr142; - case 125: goto tr143; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr141; - goto tr1; -case 103: - switch( (*p) ) { - case 32: goto tr144; - case 44: goto tr145; - case 125: goto tr136; - } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr144; - goto tr1; -case 104: - switch( (*p) ) { - case 32: goto tr145; - case 34: goto tr135; + _keys = _json_trans_keys + _json_key_offsets[cs]; + _trans = _json_index_offsets[cs]; + + _klen = _json_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (unsigned int)(_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; } - if ( 9 <= (*p) && (*p) <= 13 ) - goto tr145; - goto tr1; -case 105: - goto tr146; + + _klen = _json_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += (unsigned int)((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; } - tr1: cs = 0; goto _again; - tr0: cs = 1; goto _again; - tr2: cs = 2; goto f0; - tr11: cs = 3; goto _again; - tr4: cs = 3; goto f2; - tr13: cs = 4; goto _again; - tr10: cs = 4; goto f5; - tr14: cs = 5; goto _again; - tr5: cs = 6; goto _again; - tr15: cs = 7; goto _again; - tr16: cs = 8; goto _again; - tr17: cs = 9; goto _again; - tr6: cs = 10; goto _again; - tr19: cs = 11; goto _again; - tr20: cs = 12; goto _again; - tr7: cs = 13; goto _again; - tr22: cs = 14; goto _again; - tr23: cs = 15; goto _again; - tr25: cs = 16; goto _again; - tr8: cs = 16; goto f3; - tr26: cs = 17; goto f7; - tr29: cs = 18; goto _again; - tr28: cs = 18; goto f9; - tr30: cs = 19; goto _again; - tr31: cs = 20; goto f5; - tr35: cs = 21; goto _again; - tr32: cs = 21; goto f10; - tr36: cs = 22; goto _again; - tr33: cs = 22; goto f10; - tr37: cs = 24; goto _again; - tr38: cs = 25; goto _again; - tr41: cs = 26; goto _again; - tr43: cs = 27; goto _again; - tr42: cs = 28; goto _again; - tr44: cs = 29; goto _again; - tr45: cs = 30; goto _again; - tr39: cs = 31; goto _again; - tr52: cs = 32; goto f18; - tr49: cs = 33; goto _again; - tr46: cs = 33; goto f14; - tr58: cs = 33; goto f21; - tr48: cs = 34; goto _again; - tr51: cs = 34; goto f17; - tr60: cs = 34; goto f23; - tr53: cs = 35; goto _again; - tr54: cs = 36; goto f19; - tr55: cs = 37; goto f20; - tr56: cs = 38; goto f20; - tr57: cs = 39; goto f20; - tr61: cs = 41; goto f24; - tr64: cs = 42; goto _again; - tr62: cs = 42; goto f24; - tr66: cs = 43; goto _again; - tr68: cs = 44; goto _again; - tr67: cs = 45; goto f25; - tr65: cs = 46; goto _again; - tr63: cs = 46; goto f24; - tr70: cs = 48; goto f27; - tr71: cs = 49; goto _again; - tr72: cs = 50; goto _again; - tr73: cs = 51; goto _again; - tr74: cs = 52; goto _again; - tr75: cs = 53; goto _again; - tr76: cs = 54; goto _again; - tr77: cs = 55; goto _again; - tr78: cs = 56; goto _again; - tr79: cs = 57; goto _again; - tr80: cs = 58; goto _again; - tr81: cs = 59; goto _again; - tr82: cs = 60; goto _again; - tr83: cs = 61; goto _again; - tr84: cs = 62; goto _again; - tr85: cs = 63; goto _again; - tr86: cs = 64; goto _again; - tr87: cs = 65; goto _again; - tr88: cs = 66; goto _again; - tr89: cs = 67; goto f28; - tr99: cs = 67; goto f31; - tr92: cs = 68; goto _again; - tr93: cs = 69; goto _again; - tr94: cs = 70; goto _again; - tr95: cs = 71; goto _again; - tr96: cs = 72; goto _again; - tr91: cs = 72; goto f28; - tr100: cs = 72; goto f31; - tr90: cs = 73; goto f29; - tr98: cs = 74; goto _again; - tr103: cs = 76; goto _again; - tr101: cs = 76; goto f32; - tr105: cs = 77; goto f35; - tr106: cs = 79; goto f0; - tr113: cs = 80; goto f4; - tr118: cs = 80; goto f6; - tr107: cs = 81; goto f1; - tr117: cs = 82; goto _again; - tr108: cs = 82; goto f2; - tr119: cs = 83; goto _again; - tr116: cs = 83; goto f5; - tr120: cs = 84; goto _again; - tr109: cs = 85; goto _again; - tr121: cs = 86; goto _again; - tr122: cs = 87; goto _again; - tr123: cs = 88; goto _again; - tr124: cs = 89; goto _again; - tr110: cs = 90; goto _again; - tr126: cs = 91; goto _again; - tr127: cs = 92; goto _again; - tr128: cs = 93; goto _again; - tr111: cs = 94; goto _again; - tr130: cs = 95; goto _again; - tr131: cs = 96; goto _again; - tr132: cs = 97; goto _again; - tr134: cs = 98; goto _again; - tr112: cs = 98; goto f3; - tr135: cs = 99; goto f7; - tr138: cs = 100; goto _again; - tr137: cs = 100; goto f9; - tr139: cs = 101; goto _again; - tr140: cs = 102; goto f5; - tr144: cs = 103; goto _again; - tr141: cs = 103; goto f10; - tr145: cs = 104; goto _again; - tr142: cs = 104; goto f10; - tr136: cs = 105; goto f8; - tr143: cs = 105; goto f11; - tr147: cs = 106; goto _again; - tr9: cs = 106; goto f4; - tr12: cs = 106; goto f6; - tr148: cs = 106; goto f42; - tr149: cs = 106; goto f43; - tr150: cs = 106; goto f44; - tr151: cs = 106; goto f45; - tr152: cs = 106; goto f46; - tr3: cs = 107; goto f1; - tr18: cs = 108; goto _again; - tr21: cs = 109; goto _again; - tr24: cs = 110; goto _again; - tr27: cs = 111; goto f8; - tr34: cs = 111; goto f11; - tr40: cs = 112; goto f13; - tr47: cs = 113; goto f15; - tr50: cs = 113; goto f16; - tr59: cs = 113; goto f22; - tr69: cs = 114; goto f26; - tr97: cs = 115; goto f30; - tr102: cs = 116; goto f33; - tr104: cs = 116; goto f34; - tr114: cs = 117; goto f36; - tr115: cs = 117; goto f37; - tr125: cs = 117; goto f38; - tr129: cs = 117; goto f39; - tr133: cs = 117; goto f40; - tr146: cs = 117; goto f41; - - f13: _acts = _json_actions + 3; goto execFuncs; - f14: _acts = _json_actions + 5; goto execFuncs; - f17: _acts = _json_actions + 7; goto execFuncs; - f20: _acts = _json_actions + 9; goto execFuncs; - f23: _acts = _json_actions + 11; goto execFuncs; - f18: _acts = _json_actions + 13; goto execFuncs; - f15: _acts = _json_actions + 15; goto execFuncs; - f24: _acts = _json_actions + 17; goto execFuncs; - f25: _acts = _json_actions + 19; goto execFuncs; - f26: _acts = _json_actions + 21; goto execFuncs; - f27: _acts = _json_actions + 23; goto execFuncs; - f33: _acts = _json_actions + 25; goto execFuncs; - f5: _acts = _json_actions + 27; goto execFuncs; - f9: _acts = _json_actions + 29; goto execFuncs; - f10: _acts = _json_actions + 31; goto execFuncs; - f8: _acts = _json_actions + 33; goto execFuncs; - f2: _acts = _json_actions + 35; goto execFuncs; - f6: _acts = _json_actions + 37; goto execFuncs; - f42: _acts = _json_actions + 39; goto execFuncs; - f4: _acts = _json_actions + 41; goto execFuncs; - f45: _acts = _json_actions + 43; goto execFuncs; - f43: _acts = _json_actions + 45; goto execFuncs; - f44: _acts = _json_actions + 47; goto execFuncs; - f46: _acts = _json_actions + 49; goto execFuncs; - f36: _acts = _json_actions + 51; goto execFuncs; - f16: _acts = _json_actions + 53; goto execFuncs; - f19: _acts = _json_actions + 56; goto execFuncs; - f21: _acts = _json_actions + 59; goto execFuncs; - f22: _acts = _json_actions + 62; goto execFuncs; - f29: _acts = _json_actions + 65; goto execFuncs; - f31: _acts = _json_actions + 68; goto execFuncs; - f30: _acts = _json_actions + 71; goto execFuncs; - f35: _acts = _json_actions + 74; goto execFuncs; - f32: _acts = _json_actions + 77; goto execFuncs; - f7: _acts = _json_actions + 80; goto execFuncs; - f11: _acts = _json_actions + 83; goto execFuncs; - f1: _acts = _json_actions + 86; goto execFuncs; - f37: _acts = _json_actions + 89; goto execFuncs; - f0: _acts = _json_actions + 92; goto execFuncs; - f40: _acts = _json_actions + 95; goto execFuncs; - f38: _acts = _json_actions + 98; goto execFuncs; - f39: _acts = _json_actions + 101; goto execFuncs; - f3: _acts = _json_actions + 104; goto execFuncs; - f41: _acts = _json_actions + 107; goto execFuncs; - f34: _acts = _json_actions + 110; goto execFuncs; - f28: _acts = _json_actions + 114; goto execFuncs; - -execFuncs: - _nacts = *_acts++; - while ( _nacts-- > 0 ) { - switch ( *_acts++ ) { +_match: + _trans = _json_indicies[_trans]; + cs = _json_trans_targs[_trans]; + + if ( _json_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _json_actions + _json_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { case 1: #line 2561 "upb/json/parser.rl" - { p--; {cs = stack[--top];goto _again;} } + { p--; {cs = stack[--top]; goto _again;} } break; case 2: #line 2563 "upb/json/parser.rl" @@ -16111,7 +15515,7 @@ execFuncs: break; case 9: #line 2588 "upb/json/parser.rl" - { p--; {cs = stack[--top];goto _again;} } + { p--; {cs = stack[--top]; goto _again;} } break; case 10: #line 2600 "upb/json/parser.rl" @@ -16123,7 +15527,7 @@ execFuncs: break; case 12: #line 2603 "upb/json/parser.rl" - { p--; {cs = stack[--top];goto _again;} } + { p--; {cs = stack[--top]; goto _again;} } break; case 13: #line 2608 "upb/json/parser.rl" @@ -16151,7 +15555,7 @@ execFuncs: break; case 19: #line 2617 "upb/json/parser.rl" - { p--; {cs = stack[--top];goto _again;} } + { p--; {cs = stack[--top]; goto _again;} } break; case 20: #line 2622 "upb/json/parser.rl" @@ -16171,7 +15575,7 @@ execFuncs: break; case 24: #line 2635 "upb/json/parser.rl" - { p--; {cs = stack[--top];goto _again;} } + { p--; {cs = stack[--top]; goto _again;} } break; case 25: #line 2640 "upb/json/parser.rl" @@ -16281,12 +15685,11 @@ execFuncs: break; case 43: #line 2727 "upb/json/parser.rl" - { p--; {cs = stack[--top];goto _again;} } + { p--; {cs = stack[--top]; goto _again;} } break; -#line 3707 "upb/json/parser.c" +#line 3111 "upb/json/parser.c" } } - goto _again; _again: if ( cs == 0 ) @@ -16302,7 +15705,7 @@ _again: switch ( *__acts++ ) { case 0: #line 2559 "upb/json/parser.rl" - { p--; {cs = stack[--top]; if ( p == pe ) + { p--; {cs = stack[--top]; if ( p == pe ) goto _test_eof; goto _again;} } break; @@ -16326,7 +15729,7 @@ goto _again;} } #line 2722 "upb/json/parser.rl" { end_subobject_full(parser); } break; -#line 3750 "upb/json/parser.c" +#line 3153 "upb/json/parser.c" } } } @@ -16383,7 +15786,7 @@ static void json_parser_reset(upb_json_parser *p) { /* Emit Ragel initialization of the parser. */ -#line 3807 "upb/json/parser.c" +#line 3210 "upb/json/parser.c" { cs = json_start; top = 0; @@ -17298,7 +16701,6 @@ static void *startseq_fieldmask(void *closure, const void *handler_data) { UPB_UNUSED(handler_data); p->depth_++; p->first_elem_[p->depth_] = true; - print_data(p, "\"", 1); return closure; } @@ -17306,7 +16708,6 @@ static bool endseq_fieldmask(void *closure, const void *handler_data) { upb_json_printer *p = closure; UPB_UNUSED(handler_data); p->depth_--; - print_data(p, "\"", 1); return true; } @@ -17526,6 +16927,29 @@ static bool printer_endmsg_noframe( return true; } +static bool printer_startmsg_fieldmask( + void *closure, const void *handler_data) { + upb_json_printer *p = closure; + UPB_UNUSED(handler_data); + if (p->depth_ == 0) { + upb_bytessink_start(p->output_, 0, &p->subc_); + } + print_data(p, "\"", 1); + return true; +} + +static bool printer_endmsg_fieldmask( + void *closure, const void *handler_data, upb_status *s) { + upb_json_printer *p = closure; + UPB_UNUSED(handler_data); + UPB_UNUSED(s); + print_data(p, "\"", 1); + if (p->depth_ == 0) { + upb_bytessink_end(p->output_); + } + return true; +} + static void *scalar_startstr_onlykey( void *closure, const void *handler_data, size_t size_hint) { upb_json_printer *p = closure; @@ -17579,8 +17003,8 @@ void printer_sethandlers_fieldmask(const void *closure, upb_handlers *h) { upb_handlers_setstartseq(h, f, startseq_fieldmask, &empty_attr); upb_handlers_setendseq(h, f, endseq_fieldmask, &empty_attr); - upb_handlers_setstartmsg(h, printer_startmsg_noframe, &empty_attr); - upb_handlers_setendmsg(h, printer_endmsg_noframe, &empty_attr); + upb_handlers_setstartmsg(h, printer_startmsg_fieldmask, &empty_attr); + upb_handlers_setendmsg(h, printer_endmsg_fieldmask, &empty_attr); upb_handlers_setstartstr(h, f, repeated_startstr_fieldmask, &empty_attr); upb_handlers_setstring(h, f, repeated_str_fieldmask, &empty_attr); diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php index 7b5cc7d1f3..0beedba333 100644 --- a/php/src/Google/Protobuf/Internal/GPBUtil.php +++ b/php/src/Google/Protobuf/Internal/GPBUtil.php @@ -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); diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index 61527e899a..4107d65bb6 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -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()); + } + }