Ensure that SSL YouTube URLs receive SSL embeds.

props adamsilverstein, Otto42, JayCC.
fixes #23149.


git-svn-id: https://develop.svn.wordpress.org/trunk@26978 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2014-01-17 19:45:51 +00:00
parent 9b9de4ee1f
commit d0bb9e8f86
2 changed files with 23 additions and 2 deletions

View File

@ -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.
*

View File

@ -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(