|
1 | 1 | import os |
2 | 2 | from datetime import datetime |
3 | 3 |
|
| 4 | +from django.core.exceptions import SuspiciousOperation |
4 | 5 | from django.core.serializers.json import DjangoJSONEncoder |
5 | 6 | from django.test import SimpleTestCase |
6 | 7 | from django.utils.deprecation import RemovedInDjango60Warning |
@@ -124,12 +125,18 @@ def test_strip_tags(self): |
124 | 125 | ("<script>alert()</script>&h", "alert()h"), |
125 | 126 | ("><!" + ("&" * 16000) + "D", "><!" + ("&" * 16000) + "D"), |
126 | 127 | ("X<<<<br>br>br>br>X", "XX"), |
| 128 | + ("<" * 50 + "a>" * 50, ""), |
127 | 129 | ) |
128 | 130 | for value, output in items: |
129 | 131 | with self.subTest(value=value, output=output): |
130 | 132 | self.check_output(strip_tags, value, output) |
131 | 133 | self.check_output(strip_tags, lazystr(value), output) |
132 | 134 |
|
| 135 | + def test_strip_tags_suspicious_operation(self): |
| 136 | + value = "<" * 51 + "a>" * 51, "<a>" |
| 137 | + with self.assertRaises(SuspiciousOperation): |
| 138 | + strip_tags(value) |
| 139 | + |
133 | 140 | def test_strip_tags_files(self): |
134 | 141 | # Test with more lengthy content (also catching performance regressions) |
135 | 142 | for filename in ("strip_tags1.html", "strip_tags2.txt"): |
|
0 commit comments