diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-10-19 11:11:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-19 11:11:16 (GMT) |
commit | a66f279a1381dd5c1c27232ccf9f210d575e1dcc (patch) | |
tree | f496d5feb844bbac663a0f8d166e2a94bb14abf6 /Lib/test/test_urlparse.py | |
parent | d6d35d0a005bb3d1e04095074c255bf8d0b651d7 (diff) | |
download | cpython-a66f279a1381dd5c1c27232ccf9f210d575e1dcc.zip cpython-a66f279a1381dd5c1c27232ccf9f210d575e1dcc.tar.gz cpython-a66f279a1381dd5c1c27232ccf9f210d575e1dcc.tar.bz2 |
bpo-34866: Adding max_num_fields to cgi.FieldStorage (GH-9660)
Adding `max_num_fields` to `cgi.FieldStorage` to make DOS attacks harder by
limiting the number of `MiniFieldStorage` objects created by `FieldStorage`.
(cherry picked from commit 209144831b0a19715bda3bd72b14a3e6192d9cc1)
Co-authored-by: matthewbelisle-wf <matthew.belisle@workiva.com>
Diffstat (limited to 'Lib/test/test_urlparse.py')
-rw-r--r-- | Lib/test/test_urlparse.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index ddee1c3..be50b47 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -879,6 +879,13 @@ class UrlParseTestCase(unittest.TestCase): errors="ignore") self.assertEqual(result, [('key', '\u0141-')]) + def test_parse_qsl_max_num_fields(self): + with self.assertRaises(ValueError): + urllib.parse.parse_qs('&'.join(['a=a']*11), max_num_fields=10) + with self.assertRaises(ValueError): + urllib.parse.parse_qs(';'.join(['a=a']*11), max_num_fields=10) + urllib.parse.parse_qs('&'.join(['a=a']*10), max_num_fields=10) + def test_urlencode_sequences(self): # Other tests incidentally urlencode things; test non-covered cases: # Sequence and object values. |