diff options
Diffstat (limited to 'Lib/test/test_fpformat.py')
-rw-r--r-- | Lib/test/test_fpformat.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_fpformat.py b/Lib/test/test_fpformat.py index e6de3b0..428623e 100644 --- a/Lib/test/test_fpformat.py +++ b/Lib/test/test_fpformat.py @@ -67,6 +67,16 @@ class FpformatTest(unittest.TestCase): else: self.fail("No exception on non-numeric sci") + def test_REDOS(self): + # This attack string will hang on the old decoder pattern. + attack = '+0' + ('0' * 1000000) + '++' + digs = 5 # irrelevant + + # fix returns input if it does not decode + self.assertEqual(fpformat.fix(attack, digs), attack) + # sci raises NotANumber + with self.assertRaises(NotANumber): + fpformat.sci(attack, digs) def test_main(): run_unittest(FpformatTest) |