Fix #2533: Prevent removal of '/' when redirect from url is just '/' (#2721)

This commit is contained in:
Ludolf Takens 2016-06-16 12:48:45 +02:00 committed by Matt Westcott
parent 852a6de301
commit e995bc0e19
5 changed files with 7 additions and 2 deletions

View file

@ -14,7 +14,7 @@ Changelog
* Fix: Email templates and document uploader now support custom `STATICFILES_STORAGE` (Jonny Scholes)
* Fix: Removed alignment options (deprecated in HTML and not rendered by Wagtail) from `TableBlock` context menu (Moritz Pfeiffer)
* Fix: Fixed incorrect CSS path on ModelAdmin's "choose a parent page" view
* Fix: Prevent empty redirect by overnormalisation (Franklin Kingma, Ludolf Takens)
1.5.2 (08.06.2016)
~~~~~~~~~~~~~~~~~~

View file

@ -143,6 +143,8 @@ Contributors
* Jonny Scholes
* Richard McMillan
* Johannes Spielmann
* Franklin Kingma
* Ludolf Takens
Translators
===========

View file

@ -29,6 +29,7 @@ Bug fixes
* Email templates and document uploader now support custom ``STATICFILES_STORAGE`` (Jonny Scholes)
* Removed alignment options (deprecated in HTML and not rendered by Wagtail) from ``TableBlock`` context menu (Moritz Pfeiffer)
* Fixed incorrect CSS path on ModelAdmin's "choose a parent page" view
* Prevent empty redirect by overnormalisation
Upgrade considerations

View file

@ -64,7 +64,7 @@ class Redirect(models.Model):
if not path.startswith('/'):
path = '/' + path
if path.endswith('/'):
if path.endswith('/') and len(path) > 1:
path = path[:-1]
# Parameters must be sorted alphabetically

View file

@ -76,6 +76,8 @@ class TestRedirects(TestCase):
'/Hello/world.htm;fizz=three;buzz=five?foo=Bar&Baz=quux2'
))
self.assertEqual('/', normalise_path('/')) # '/' should stay '/'
# Normalise some rubbish to make sure it doesn't crash
normalise_path('This is not a URL')
normalise_path('//////hello/world')