WordPress.org

Make WordPress Core

Changeset 40847


Ignore:
Timestamp:
05/26/17 23:09:42 (4 weeks ago)
Author:
westonruter
Message:

Widgets: Normalize YouTube and Vimeo URLs in video shortcode (primarily for Video widget) to work around ME.js 2.22 bug.

Props timmydcrawford, jnylen0, westonruter.
See #32417, #39994.
Fixes #40866.

Location:
trunk
Files:
2 edited

Legend:

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

    r40813 r40847  
    25472547    } 
    25482548 
     2549    // Mediaelement has issues with some URL formats for Vimeo and YouTube, so 
     2550    // update the URL to prevent the ME.js player from breaking. 
     2551    if ( 'mediaelement' === $library ) { 
     2552        if ( $is_youtube ) { 
     2553            // Remove `feature` query arg and force SSL - see #40866. 
     2554            $atts['src'] = remove_query_arg( 'feature', $atts['src'] ); 
     2555            $atts['src'] = set_url_scheme( $atts['src'], 'https' ); 
     2556        } elseif ( $is_vimeo ) { 
     2557            // Remove all query arguments and force SSL - see #40866. 
     2558            $parsed_vimeo_url = wp_parse_url( $atts['src'] ); 
     2559            $atts['src'] = 'https://' . $parsed_vimeo_url['host'] . $parsed_vimeo_url['path']; 
     2560        } 
     2561    } 
     2562 
    25492563    /** 
    25502564     * Filters the class attribute for the video shortcode output container. 
  • trunk/tests/phpunit/tests/media.php

    r40809 r40847  
    725725 
    726726    /** 
     727     * @ticket 40866 
     728     * @depends test_video_shortcode_body 
     729     */ 
     730    function test_wp_video_shortcode_youtube_remove_feature() { 
     731        $actual = wp_video_shortcode( array( 
     732            'src' => 'https://www.youtube.com/watch?v=i_cVJgIz_Cs&feature=youtu.be', 
     733        ) ); 
     734 
     735        $this->assertNotContains( 'feature=youtu.be', $actual ); 
     736    } 
     737 
     738    /** 
     739     * @ticket 40866 
     740     * @depends test_video_shortcode_body 
     741     */ 
     742    function test_wp_video_shortcode_youtube_force_ssl() { 
     743        $actual = wp_video_shortcode( array( 
     744            'src' => 'http://www.youtube.com/watch?v=i_cVJgIz_Cs', 
     745        ) ); 
     746 
     747        $this->assertContains( 'src="https://www.youtube.com/watch?v=i_cVJgIz_Cs', $actual ); 
     748    } 
     749 
     750    /** 
     751     * @ticket 40866 
     752     * @depends test_video_shortcode_body 
     753     */ 
     754    function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() { 
     755        $actual = wp_video_shortcode( array( 
     756            'src' => 'http://vimeo.com/190372437?blah=meh', 
     757        ) ); 
     758 
     759        $this->assertContains( 'src="https://vimeo.com/190372437', $actual ); 
     760        $this->assertNotContains( 'blah=meh', $actual ); 
     761    } 
     762 
     763    /** 
    727764     * Test [video] shortcode processing 
    728765     * 
Note: See TracChangeset for help on using the changeset viewer.