mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[1.5.x] Fixed #18210 -- Escaped special characters in reverse prefixes.
Ensured that special characters passed in to reverse via the
prefix argument are properly escaped so that calls to
django.utils.regex_helpers.normalize and/or string formatting
operations don't result in exceptions.
Thanks to toofishes for the error report.
Backport of 90e530978d from master.
This commit is contained in:
committed by
Jannis Leidel
parent
0e3f7814d7
commit
dd740e2b2e
@@ -171,6 +171,18 @@ class URLPatternReverse(TestCase):
|
||||
# Reversing None should raise an error, not return the last un-named view.
|
||||
self.assertRaises(NoReverseMatch, reverse, None)
|
||||
|
||||
def test_prefix_braces(self):
|
||||
self.assertEqual('/%7B%7Binvalid%7D%7D/includes/non_path_include/',
|
||||
reverse('non_path_include', prefix='/{{invalid}}/'))
|
||||
|
||||
def test_prefix_parenthesis(self):
|
||||
self.assertEqual('/bogus%29/includes/non_path_include/',
|
||||
reverse('non_path_include', prefix='/bogus)/'))
|
||||
|
||||
def test_prefix_format_char(self):
|
||||
self.assertEqual('/bump%2520map/includes/non_path_include/',
|
||||
reverse('non_path_include', prefix='/bump%20map/'))
|
||||
|
||||
class ResolverTests(unittest.TestCase):
|
||||
def test_resolver_repr(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user