[C++] Allow user specified recursion depth in json_util functions
What language does this apply to? C++
Describe the problem you are trying to solve. Allow the recursion limit when writing JSONs to be increased.
Describe the solution you'd like
An additional argument to each of the functions in json_uti.h/cc that allows a user specified recursion limit. This could be given the a default value to preserve backwards compatibility. For the MessageTo... and BinaryTo... functions set_max_recursion_depth could then be called on proto_source in BinaryToJsonStream. Something equivalent should be done to increase the parse limit.
Describe alternatives you've considered
A compile time option that allows the default recursion depth specified by kDefaultMaxRecursionDepth in protostream_objectsource.cc to be increased.
This seems like something we could accept a contribution for if introduced in a backwards compatible manner.
@haberman WDYT?
This seems reasonable. I agree we could accept a contribution if it was done in a backwards-compatible manner.
By the way, protostream_objectsource.cc is not part of our repo anymore. It was removed in 2022: https://github.com/protocolbuffers/protobuf/commit/32bea52ee660abeb6a2891e3dce979a909cbd6ea
This seems reasonable. I agree we could accept a contribution if it was done in a backwards-compatible manner.
By the way,
protostream_objectsource.ccis not part of our repo anymore. It was removed in 2022: 32bea52
If the file protostream_objectsource.cc is no longer part of the repo, Is there an alternative other than compile time option or source code change, by increasing kDefaultMaxRecursionDepth, for protobuf users?
Is there an alternative other than compile time option or source code change, by increasing kDefaultMaxRecursionDepth, for protobuf users?
No, that is what this issue is proposing to fix.
Currently the internal ParseOptions has a field recursion_depth that allows this to be configured at runtime: https://github.com/protocolbuffers/protobuf/blob/0ed61f0b15343d6450a55413748aa71a6ded0842/src/google/protobuf/json/internal/lexer.h#L48-L50
However the public ParseOptions struct does not have a field for this: https://github.com/protocolbuffers/protobuf/blob/0ed61f0b15343d6450a55413748aa71a6ded0842/src/google/protobuf/json/json.h#L26-L36
Probably all we need to do is add a field to the public ParseOptions struct and plumb it through to the internal one.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.