summaryrefslogtreecommitdiff
path: root/simplejson/tests
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2023-04-04 10:59:13 -0700
committerBob Ippolito <bob@redivi.com>2023-04-04 10:59:13 -0700
commit59dac4e82cd6766fc31a9389d573d732580eaab5 (patch)
tree2cba0cbde6419fa11c6111d82f64b989c46455ec /simplejson/tests
parent1e495c1199f56c2e8e7931f20bda7481842e18ff (diff)
downloadsimplejson-59dac4e82cd6766fc31a9389d573d732580eaab5.tar.gz
SJ-PT-23-03: Backport integer string length limitation to limit quadratic parsing
Diffstat (limited to 'simplejson/tests')
-rw-r--r--simplejson/tests/test_decode.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/simplejson/tests/test_decode.py b/simplejson/tests/test_decode.py
index 6960ee5..317b4f9 100644
--- a/simplejson/tests/test_decode.py
+++ b/simplejson/tests/test_decode.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import
import decimal
from unittest import TestCase
+import sys
import simplejson as json
from simplejson.compat import StringIO, b, binary_type
from simplejson import OrderedDict
@@ -117,3 +118,10 @@ class TestDecode(TestCase):
diff = id(x) - id(y)
self.assertRaises(ValueError, j.scan_once, y, diff)
self.assertRaises(ValueError, j.raw_decode, y, i)
+
+ def test_bounded_int(self):
+ # SJ-PT-23-03, limit quadratic number parsing per Python 3.11
+ max_str_digits = getattr(sys, 'get_int_max_str_digits', lambda: 4300)()
+ s = '1' + '0' * (max_str_digits - 1)
+ self.assertEqual(json.loads(s), int(s))
+ self.assertRaises(ValueError, json.loads, s + '0')