mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-15 02:33:13 +00:00
Strip whitespace from redirect paths. Fixes #1350
This commit is contained in:
parent
dc6cdd2ba2
commit
97e489e959
2 changed files with 5 additions and 0 deletions
|
|
@ -41,6 +41,9 @@ class Redirect(models.Model):
|
|||
|
||||
@staticmethod
|
||||
def normalise_path(url):
|
||||
# Strip whitespace
|
||||
url = url.strip()
|
||||
|
||||
# Parse url
|
||||
url_parsed = urlparse(url)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class TestRedirects(TestCase):
|
|||
self.assertEqual(path, normalise_path('Hello/world.html/?foo=Bar&Baz=quux2')) # Trailing slashes are ignored
|
||||
self.assertEqual(path, normalise_path('/Hello/world.html?foo=Bar&Baz=quux2#cool')) # Fragments are ignored
|
||||
self.assertEqual(path, normalise_path('/Hello/world.html?Baz=quux2&foo=Bar')) # Order of query string parameters are ignored
|
||||
self.assertEqual(path, normalise_path(' /Hello/world.html?foo=Bar&Baz=quux2')) # Leading whitespace
|
||||
self.assertEqual(path, normalise_path('/Hello/world.html?foo=Bar&Baz=quux2 ')) # Trailing whitespace
|
||||
|
||||
# Test against different paths
|
||||
self.assertNotEqual(path, normalise_path('/hello/world.html?foo=Bar&Baz=quux2')) # 'hello' is lowercase
|
||||
|
|
|
|||
Loading…
Reference in a new issue