[JSON] fix bug that incorrectly allowed trailing commas after an empty container (#33158)
This commit is contained in:
parent
9c59671936
commit
ba1b8b15ea
|
|
@ -476,6 +476,7 @@ JsonReader::Status JsonReader::Run() {
|
|||
return Status::GRPC_JSON_PARSE_ERROR;
|
||||
}
|
||||
state_ = State::GRPC_JSON_STATE_VALUE_END;
|
||||
container_just_begun_ = false;
|
||||
EndContainer();
|
||||
if (stack_.empty()) {
|
||||
state_ = State::GRPC_JSON_STATE_END;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ TEST(XdsOverrideHostConfigParsingTest, ReportsChildPolicyShouldBeArray) {
|
|||
" \"loadBalancingConfig\":[{\n"
|
||||
" \"xds_override_host_experimental\":{\n"
|
||||
" \"childPolicy\":{\n"
|
||||
" \"grpclb\":{},\n"
|
||||
" \"grpclb\":{}\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }]\n"
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ TEST(Json, Keywords) {
|
|||
void RunParseFailureTest(const char* input) {
|
||||
gpr_log(GPR_INFO, "parsing string \"%s\" - should fail", input);
|
||||
auto json = JsonParse(input);
|
||||
EXPECT_FALSE(json.ok());
|
||||
EXPECT_FALSE(json.ok()) << "input: \"" << input << "\"";
|
||||
}
|
||||
|
||||
TEST(Json, InvalidInput) {
|
||||
|
|
@ -213,6 +213,10 @@ TEST(Json, InvalidInput) {
|
|||
RunParseFailureTest("fals");
|
||||
RunParseFailureTest("0,0 ");
|
||||
RunParseFailureTest("\"foo\",[]");
|
||||
RunParseFailureTest("{\"field\": {},}");
|
||||
RunParseFailureTest("[{},]");
|
||||
RunParseFailureTest("{\"field\": [],}");
|
||||
RunParseFailureTest("[[],]");
|
||||
}
|
||||
|
||||
TEST(Json, UnterminatedString) { RunParseFailureTest("\"\\x"); }
|
||||
|
|
|
|||
Loading…
Reference in New Issue