kopia lustrzana https://github.com/wagtail/wagtail
Fix OEmbed endpoints
rodzic
92b4f68c67
commit
83e6a551fe
|
@ -21,6 +21,7 @@ Changelog
|
|||
|
||||
* Fix: Migration for addition of `Page.draft_title` field is now reversible (Venelin Stoykov)
|
||||
* Fix: Fixed failure on application startup when `ManifestStaticFilesStorage` is in use and `collectstatic` has not yet been run (Matt Westcott)
|
||||
* Fix: Fixed handling of Vimeo and other oEmbed providers with a format parameter in the endpoint URL (Mitchel Cabuloy)
|
||||
|
||||
|
||||
1.12.1 (30.08.2017)
|
||||
|
|
|
@ -15,3 +15,4 @@ Bug fixes
|
|||
|
||||
* Migration for addition of ``Page.draft_title`` field is now reversible (Venelin Stoykov)
|
||||
* Fixed failure on application startup when ``ManifestStaticFilesStorage`` is in use and ``collectstatic`` has not yet been run (Matt Westcott)
|
||||
* Fixed handling of Vimeo and other oEmbed providers with a format parameter in the endpoint URL (Mitchel Cabuloy)
|
||||
|
|
|
@ -26,11 +26,12 @@ class OEmbedFinder(EmbedFinder):
|
|||
for provider in providers or all_providers:
|
||||
patterns = []
|
||||
|
||||
endpoint = provider['endpoint'].replace('{format}', 'json')
|
||||
|
||||
for url in provider['urls']:
|
||||
url = url.replace('{format}', 'json')
|
||||
patterns.append(re.compile(url))
|
||||
|
||||
self._endpoints[provider['endpoint']] = patterns
|
||||
self._endpoints[endpoint] = patterns
|
||||
|
||||
if options:
|
||||
self.options = self.options.copy()
|
||||
|
|
|
@ -447,6 +447,17 @@ class TestOembed(TestCase):
|
|||
finder = OEmbedFinder(providers=[oembed_providers.twitter])
|
||||
self.assertFalse(finder.accept("http://www.youtube.com/watch/"))
|
||||
|
||||
@patch('django.utils.six.moves.urllib.request.urlopen')
|
||||
@patch('json.loads')
|
||||
def test_endpoint_with_format_param(self, loads, urlopen):
|
||||
urlopen.return_value = self.dummy_response
|
||||
loads.return_value = {'type': 'video',
|
||||
'url': 'http://www.example.com'}
|
||||
result = OEmbedFinder().find_embed("https://vimeo.com/217403396")
|
||||
self.assertEqual(result['type'], 'video')
|
||||
request = urlopen.call_args[0][0]
|
||||
self.assertEqual(request.full_url.split('?')[0], "http://www.vimeo.com/api/oembed.json")
|
||||
|
||||
|
||||
class TestEmbedTag(TestCase):
|
||||
@patch('wagtail.wagtailembeds.embeds.get_embed')
|
||||
|
|
Ładowanie…
Reference in New Issue