diff --git a/src/wp-includes/class-oembed.php b/src/wp-includes/class-oembed.php index e465a6d1a3..15b62b5085 100644 --- a/src/wp-includes/class-oembed.php +++ b/src/wp-includes/class-oembed.php @@ -27,8 +27,10 @@ class WP_oEmbed { */ function __construct() { $providers = array( - '#https?://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), - 'http://youtu.be/*' => array( 'http://www.youtube.com/oembed', false ), + '#http://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), + '#https://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), + '#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ), + '#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ), 'http://blip.tv/*' => array( 'http://blip.tv/oembed/', false ), '#https?://(www\.)?vimeo\.com/.*#i' => array( 'http://vimeo.com/api/oembed.{format}', true ), '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'http://www.dailymotion.com/services/oembed', true ), @@ -54,6 +56,7 @@ class WP_oEmbed { '#https?://rd\.io/x/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ), '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), ); + /** * Filter the list of oEmbed providers. * diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index a78f971812..e18f2a5596 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -114,6 +114,24 @@ CAP; $this->assertFalse( wp_oembed_remove_provider( 'http://foo.bar/*' ) ); } + /** + * Test secure youtube.com embeds + * + * @ticket 23149 + */ + function test_youtube_com_secure_embed() { + global $wp_embed; + + $out = wp_oembed_get( 'http://www.youtube.com/watch?v=oHg5SJYRHA0' ); + $this->assertContains( 'http://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out ); + + $out = wp_oembed_get( 'https://www.youtube.com/watch?v=oHg5SJYRHA0' ); + $this->assertContains( 'https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out ); + + $out = wp_oembed_get( 'https://youtu.be/zHjMoNQN7s0' ); + $this->assertContains( 'https://www.youtube.com/embed/zHjMoNQN7s0?feature=oembed', $out ); + } + function test_wp_prepare_attachment_for_js() { // Attachment without media $id = wp_insert_attachment(array(