summaryrefslogtreecommitdiff
path: root/Lib/test/test_http_cookiejar.py
diff options
context:
space:
mode:
authorlarryhastings <larry@hastings.org>2020-06-12 06:07:07 -0400
committerGitHub <noreply@github.com>2020-06-12 06:07:07 -0400
commitb4c34b56aa4da179e5cd1ce9e58ba832db1cda64 (patch)
tree49296e3e222a3bc8f7a90939c177c8c3bd881f93 /Lib/test/test_http_cookiejar.py
parent3ffaa5e3d0f82f3f7571ad12bb9f07364875409b (diff)
parent55a6a16a46239a71b635584e532feb8b17ae7fdf (diff)
downloadcpython-git-travis-3.5.tar.gz
Merge branch '3.5' into travis-3.5travis-3.5
Diffstat (limited to 'Lib/test/test_http_cookiejar.py')
-rw-r--r--Lib/test/test_http_cookiejar.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 767b0fd137..218edeb9e8 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -122,6 +122,13 @@ class DateTimeTests(unittest.TestCase):
"http2time(%s) is not None\n"
"http2time(test) %s" % (test, http2time(test)))
+ def test_http2time_redos_regression_actually_completes(self):
+ # LOOSE_HTTP_DATE_RE was vulnerable to malicious input which caused catastrophic backtracking (REDoS).
+ # If we regress to cubic complexity, this test will take a very long time to succeed.
+ # If fixed, it should complete within a fraction of a second.
+ http2time("01 Jan 1970{}00:00:00 GMT!".format(" " * 10 ** 5))
+ http2time("01 Jan 1970 00:00:00{}GMT!".format(" " * 10 ** 5))
+
def test_iso2time(self):
def parse_date(text):
return time.gmtime(iso2time(text))[:6]
@@ -181,6 +188,12 @@ class DateTimeTests(unittest.TestCase):
"iso2time(%s) is not None\n"
"iso2time(test) %s" % (test, iso2time(test)))
+ def test_iso2time_performance_regression(self):
+ # If ISO_DATE_RE regresses to quadratic complexity, this test will take a very long time to succeed.
+ # If fixed, it should complete within a fraction of a second.
+ iso2time('1994-02-03{}14:15:29 -0100!'.format(' '*10**6))
+ iso2time('1994-02-03 14:15:29{}-0100!'.format(' '*10**6))
+
class HeaderTests(unittest.TestCase):