skeleton: ignore pages with bad template redirection (#23613)
This commit is contained in:
parent
db4436daff
commit
8630b9ee32
|
@ -200,7 +200,10 @@ def skeleton(request):
|
|||
# look in redirect pages after the best match for the source
|
||||
redirect_pages = Page.objects.exclude(redirect_url__isnull=True).exclude(redirect_url='')
|
||||
for page in redirect_pages:
|
||||
redirect_url = utils.get_templated_url(page.redirect_url)
|
||||
try:
|
||||
redirect_url = utils.get_templated_url(page.redirect_url)
|
||||
except utils.TemplateError:
|
||||
continue
|
||||
if source.startswith(redirect_url):
|
||||
if selected_page is None or len(redirect_url) > len(selected_page.get_redirect_url()):
|
||||
selected_page = page
|
||||
|
|
|
@ -207,6 +207,14 @@ def test_page_skeleton(app):
|
|||
resp = app.get('/__skeleton__/?source=%s' % urllib.quote('http://127.0.0.1:8999/'))
|
||||
assert 'http://testserver/plop' in resp.body
|
||||
|
||||
# add a bad redirection page (don't use it, do not crash)
|
||||
page = Page(title='BadRedirection', slug='badredir', template_name='standard',
|
||||
redirect_url='[foo_bar]')
|
||||
page.save()
|
||||
resp = app.get('/__skeleton__/?source=%s' % urllib.quote('http://example.net/foo/bar'))
|
||||
resp = app.get('/__skeleton__/?source=%s' % urllib.quote('http://example.net/badredir'))
|
||||
|
||||
|
||||
def test_subpage_location(app):
|
||||
Page.objects.all().delete()
|
||||
|
||||
|
|
Loading…
Reference in New Issue