Make WordPress Core

Ticket #41746: 41746.patch

File 41746.patch, 1.9 KB (added by dougal, 7 years ago)

Use canonical provider url param in discovery, if provided

  • wp-includes/class-oembed.php

     
    7474                        '#https?://(www\.)?twitter\.com/\w{1,15}/lists/.*#i'       => array( 'https://publish.twitter.com/oembed',                        true  ),
    7575                        '#https?://(www\.)?twitter\.com/\w{1,15}/timelines/.*#i'   => array( 'https://publish.twitter.com/oembed',                        true  ),
    7676                        '#https?://(www\.)?twitter\.com/i/moments/.*#i'            => array( 'https://publish.twitter.com/oembed',                        true  ),
     77                        /** With no provider URL, forces discovery of canonical provider */
     78                        '#https?://(www\.)?twitter\.com/i/web/status(es)?/.*#i'    => array( false,                                                       true  ),
    7779                        '#https?://vine\.co/v/.*#i'                                => array( 'https://vine.co/oembed.{format}',                           true  ),
    7880                        '#https?://(www\.)?soundcloud\.com/.*#i'                   => array( 'https://soundcloud.com/oembed',                             true  ),
    7981                        '#https?://(.+?\.)?slideshare\.net/.*#i'                   => array( 'https://www.slideshare.net/api/oembed/2',                   true  ),
     
    487489        public function fetch( $provider, $url, $args = '' ) {
    488490                $args = wp_parse_args( $args, wp_embed_defaults( $url ) );
    489491
     492                /* See if the provider URL already has a 'url' parameter */
     493                $url_query = parse_url( $provider, PHP_URL_QUERY );
     494                parse_str( $url_query, $qvars );
     495                if ( isset( $qvars['url'] ) && !empty( $qvars['url'] ) ) {
     496                        /* We should consider this URL canonical */
     497                        $url = urldecode( $qvars['url'] );
     498                }
     499
    490500                $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider );
    491501                $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
    492502                $provider = add_query_arg( 'url', urlencode($url), $provider );