mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #30116 -- Simplified regex match group access with Match.__getitem__().
The method has been available since Python 3.6. The shorter syntax is also marginally faster.
This commit is contained in:
committed by
Mariusz Felisiak
parent
23f6fbdd93
commit
d6aff369ad
@@ -392,42 +392,42 @@ class AdminURLWidgetTest(SimpleTestCase):
|
||||
w = widgets.AdminURLFieldWidget()
|
||||
output = w.render('test', 'http://example.com/<sometag>some-text</sometag>')
|
||||
self.assertEqual(
|
||||
HREF_RE.search(output).groups()[0],
|
||||
HREF_RE.search(output)[1],
|
||||
'http://example.com/%3Csometag%3Esome-text%3C/sometag%3E',
|
||||
)
|
||||
self.assertEqual(
|
||||
TEXT_RE.search(output).groups()[0],
|
||||
TEXT_RE.search(output)[1],
|
||||
'http://example.com/<sometag>some-text</sometag>',
|
||||
)
|
||||
self.assertEqual(
|
||||
VALUE_RE.search(output).groups()[0],
|
||||
VALUE_RE.search(output)[1],
|
||||
'http://example.com/<sometag>some-text</sometag>',
|
||||
)
|
||||
output = w.render('test', 'http://example-äüö.com/<sometag>some-text</sometag>')
|
||||
self.assertEqual(
|
||||
HREF_RE.search(output).groups()[0],
|
||||
HREF_RE.search(output)[1],
|
||||
'http://xn--example--7za4pnc.com/%3Csometag%3Esome-text%3C/sometag%3E',
|
||||
)
|
||||
self.assertEqual(
|
||||
TEXT_RE.search(output).groups()[0],
|
||||
TEXT_RE.search(output)[1],
|
||||
'http://example-äüö.com/<sometag>some-text</sometag>',
|
||||
)
|
||||
self.assertEqual(
|
||||
VALUE_RE.search(output).groups()[0],
|
||||
VALUE_RE.search(output)[1],
|
||||
'http://example-äüö.com/<sometag>some-text</sometag>',
|
||||
)
|
||||
output = w.render('test', 'http://www.example.com/%C3%A4"><script>alert("XSS!")</script>"')
|
||||
self.assertEqual(
|
||||
HREF_RE.search(output).groups()[0],
|
||||
HREF_RE.search(output)[1],
|
||||
'http://www.example.com/%C3%A4%22%3E%3Cscript%3Ealert(%22XSS!%22)%3C/script%3E%22',
|
||||
)
|
||||
self.assertEqual(
|
||||
TEXT_RE.search(output).groups()[0],
|
||||
TEXT_RE.search(output)[1],
|
||||
'http://www.example.com/%C3%A4"><script>'
|
||||
'alert("XSS!")</script>"'
|
||||
)
|
||||
self.assertEqual(
|
||||
VALUE_RE.search(output).groups()[0],
|
||||
VALUE_RE.search(output)[1],
|
||||
'http://www.example.com/%C3%A4"><script>alert("XSS!")</script>"',
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user