utils: do not raise on Django syntax error in templated_url (#34518)
This commit is contained in:
parent
8a80889198
commit
879be68be4
|
@ -807,7 +807,11 @@ class TextCell(CellBase):
|
|||
def sub_variadic_url(match):
|
||||
attribute = match.group(1)
|
||||
url = match.group(2)
|
||||
url = utils.get_templated_url(url, context=context)
|
||||
try:
|
||||
url = utils.get_templated_url(url, context=context)
|
||||
except utils.TemplateError as e:
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning('error in templated URL (%s): %s' % (url, e))
|
||||
return '%s="%s"' % (attribute, url)
|
||||
text = re.sub(r'(href|src)="(.*?)"', sub_variadic_url, text)
|
||||
|
||||
|
|
|
@ -365,3 +365,13 @@ def test_render(app):
|
|||
response = app.get(page.get_online_url())
|
||||
assert '<meta name="description" content="page description" />' in response.text
|
||||
assert '<title>Combo - foo</title>' in response.text
|
||||
|
||||
def test_render_cell_having_href_template_error(app):
|
||||
page = Page(title=u'foo', slug='foo', template_name='standard-sidebar', order=0, description="page description")
|
||||
page.save()
|
||||
cell = TextCell(page=page,
|
||||
text='<a href="{{e-service_url}}backoffice/...">link</a>',
|
||||
order=0, placeholder='content')
|
||||
cell.save()
|
||||
response = app.get(page.get_online_url())
|
||||
assert "{{e-service_url}}backoffice/..." in response.text # href not rendered
|
||||
|
|
Loading…
Reference in New Issue