python-oauthlib/backport-Add-check-of-performance-of-ipv6-check.patch
2022-09-26 18:08:44 +08:00

29 lines
1.0 KiB
Diff

From e514826eea15f2b62bbc13da407b71552ef5ff4c Mon Sep 17 00:00:00 2001
From: Jonathan Huot <jonathan.huot@gmail.com>
Date: Fri, 2 Sep 2022 23:22:17 +0200
Subject: [PATCH] Add check of performance of ipv6 check
---
tests/test_uri_validate.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/test_uri_validate.py b/tests/test_uri_validate.py
index 3489d95..1ef8b1f 100644
--- a/tests/test_uri_validate.py
+++ b/tests/test_uri_validate.py
@@ -31,3 +31,11 @@ class UriValidateTest(TestCase):
self.assertIsNone(is_absolute_uri('wrong'))
self.assertIsNone(is_absolute_uri('http://[:1]:38432/path'))
self.assertIsNone(is_absolute_uri('http://[abcd:efgh::1]/'))
+
+ def test_recursive_regex(self):
+ from datetime import datetime
+ t0 = datetime.now()
+ self.assertIsNone(is_absolute_uri('http://[::::::::::::::::::::::::::]/path'))
+ t1 = datetime.now()
+ spent = t1 - t0
+ self.assertGreater(0.1, spent.total_seconds(), "possible recursive loop detected")
--
2.33.0