Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JSON] fix bug that incorrectly allowed trailing commas after an empty container #33158

Merged
merged 2 commits into from May 17, 2023

Conversation

markdroth
Copy link
Member

No description provided.

Copy link
Contributor

@rockspore rockspore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sort of got how the added line would help the parser return error on the } or ] right after that redundant ,. But it'd take me some more time to understand why it has always worked when the stack is not empty before that ,.

@markdroth
Copy link
Member Author

I believe the intent here is that container_just_begun_ indicates when the previous character is a { or [. We're using that to determine if it's okay to accept a } character when we're expecting an object key or a ] character when we're expecting an array element. However, the only place that we were setting it back to false was here, and that code-path was not used when we saw a } or ] character, so we were never resetting it to false in the case that the container was empty.

@markdroth markdroth added release notes: yes Indicates if PR needs to be in release notes and removed release notes: no Indicates if PR should not be in release notes labels May 17, 2023
@markdroth markdroth merged commit ba1b8b1 into grpc:master May 17, 2023
62 of 65 checks passed
@markdroth markdroth deleted the json_trailing_comma_fix branch May 17, 2023 18:42
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label May 17, 2023
wanlin31 pushed a commit that referenced this pull request May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloat/none imported Specifies if the PR has been imported to the internal repository lang/core per-call-memory/neutral per-channel-memory/neutral release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants