mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-11 00:33:17 +00:00
Embeds: Fixed crash when no HTML field is sent back from the embed provider
This commit is contained in:
parent
b41a6d730f
commit
70211c5650
2 changed files with 17 additions and 0 deletions
|
|
@ -162,6 +162,10 @@ def get_embed(url, max_width=None, finder=None):
|
|||
except (TypeError, ValueError):
|
||||
embed_dict['height'] = None
|
||||
|
||||
# Make sure html field is valid
|
||||
if 'html' not in embed_dict or not embed_dict['html']:
|
||||
embed_dict['html'] = ''
|
||||
|
||||
# Create database record
|
||||
embed, created = Embed.objects.get_or_create(
|
||||
url=url,
|
||||
|
|
|
|||
|
|
@ -79,6 +79,19 @@ class TestEmbeds(TestCase):
|
|||
# Width must be set to None
|
||||
self.assertEqual(embed.width, None)
|
||||
|
||||
def test_no_html(self) :
|
||||
def no_html_finder(url, max_width=None):
|
||||
"""
|
||||
A finder which returns everything but HTML
|
||||
"""
|
||||
embed = self.dummy_finder(url, max_width)
|
||||
embed['html'] = None
|
||||
return embed
|
||||
|
||||
embed = get_embed('www.test.com/1234', max_width=400, finder=no_html_finder)
|
||||
|
||||
self.assertEqual(embed.html, '')
|
||||
|
||||
|
||||
class TestChooser(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue