Skip to content

Commit

Permalink
Add test that tries to parse a JSON string that exceeds the recursion…
Browse files Browse the repository at this point in the history
… limit.

PiperOrigin-RevId: 663249255
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Aug 15, 2024
1 parent 840697a commit 5a22455
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/google/protobuf/internal/json_format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,11 @@ def testOtherParseErrors(self):
"Failed to parse JSON: TypeError: 'int' object is not iterable.",
)

def testManyRecursionsRaisesParseError(self):
num_recursions = 1050
text = ('{"a":' * num_recursions) + '""' + ('}' * num_recursions)
with self.assertRaises(json_format.ParseError):
json_format.Parse(text, json_format_proto3_pb2.TestMessage())

if __name__ == '__main__':
unittest.main()

0 comments on commit 5a22455

Please sign in to comment.