summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_text.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-02-24 16:22:43 -0500
committerTim Graham <timograham@gmail.com>2018-03-01 11:58:41 -0500
commitd17974a287a6ea2e361daff88fcc004cbd6835fa (patch)
treed011b72a61adfe4f006af2a47212f0d0e78ba6c4 /tests/utils_tests/test_text.py
parent1ca63a66ef3163149ad822701273e8a1844192c2 (diff)
[1.8.x] Fixed CVE-2018-7537 -- Fixed catastrophic backtracking in django.utils.text.Truncator.
Thanks James Davis for suggesting the fix.
Diffstat (limited to 'tests/utils_tests/test_text.py')
-rw-r--r--tests/utils_tests/test_text.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py
index 084645da27..a66f9258c9 100644
--- a/tests/utils_tests/test_text.py
+++ b/tests/utils_tests/test_text.py
@@ -144,6 +144,10 @@ class TestUtilsText(SimpleTestCase):
self.assertEqual('<p>I &lt;3 python...</p>',
truncator.words(3, '...', html=True))
+ re_tag_catastrophic_test = ('</a' + '\t' * 50000) + '//>'
+ truncator = text.Truncator(re_tag_catastrophic_test)
+ self.assertEqual(re_tag_catastrophic_test, truncator.words(500, html=True))
+
def test_wrap(self):
digits = '1234 67 9'
self.assertEqual(text.wrap(digits, 100), '1234 67 9')