Make WordPress Core

Changeset 26978


Ignore:
Timestamp:
01/17/2014 07:45:51 PM (10 years ago)
Author:
nacin
Message:

Ensure that SSL YouTube URLs receive SSL embeds.

props adamsilverstein, Otto42, JayCC.
fixes #23149.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-oembed.php

    r26968 r26978  
    2828    function __construct() {
    2929        $providers = array(
    30             '#https?://(www\.)?youtube\.com/watch.*#i'            => array( 'http://www.youtube.com/oembed',                      true  ),
    31             'http://youtu.be/*'                                   => array( 'http://www.youtube.com/oembed',                      false ),
     30            '#http://(www\.)?youtube\.com/watch.*#i'              => array( 'http://www.youtube.com/oembed',                      true  ),
     31            '#https://(www\.)?youtube\.com/watch.*#i'             => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
     32            '#http://youtu\.be/.*#i'                              => array( 'http://www.youtube.com/oembed',                      true  ),
     33            '#https://youtu\.be/.*#i'                             => array( 'http://www.youtube.com/oembed?scheme=https',         true  ),
    3234            'http://blip.tv/*'                                    => array( 'http://blip.tv/oembed/',                             false ),
    3335            '#https?://(www\.)?vimeo\.com/.*#i'                   => array( 'http://vimeo.com/api/oembed.{format}',               true  ),
     
    5557            '#https?://(open|play)\.spotify\.com/.*#i'            => array( 'https://embed.spotify.com/oembed/',                  true  ),
    5658        );
     59
    5760        /**
    5861         * Filter the list of oEmbed providers.
  • trunk/tests/phpunit/tests/media.php

    r25409 r26978  
    113113        $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) );
    114114        $this->assertFalse( wp_oembed_remove_provider( 'http://foo.bar/*' ) );
     115    }
     116
     117    /**
     118     * Test secure youtube.com embeds
     119     *
     120     * @ticket 23149
     121     */
     122    function test_youtube_com_secure_embed() {
     123        global $wp_embed;
     124
     125        $out = wp_oembed_get( 'http://www.youtube.com/watch?v=oHg5SJYRHA0' );
     126        $this->assertContains( 'http://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out );
     127
     128        $out = wp_oembed_get( 'https://www.youtube.com/watch?v=oHg5SJYRHA0' );
     129        $this->assertContains( 'https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out );
     130
     131        $out = wp_oembed_get( 'https://youtu.be/zHjMoNQN7s0' );
     132        $this->assertContains( 'https://www.youtube.com/embed/zHjMoNQN7s0?feature=oembed', $out );
    115133    }
    116134
Note: See TracChangeset for help on using the changeset viewer.