diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index 81d83d8..a723929 100644
a
|
b
|
function wp_video_shortcode( $attr, $content = '' ) { |
2546 | 2546 | wp_enqueue_script( 'wp-mediaelement' ); |
2547 | 2547 | } |
2548 | 2548 | |
| 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 | |
2549 | 2563 | /** |
2550 | 2564 | * Filters the class attribute for the video shortcode output container. |
2551 | 2565 | * |
diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php
index bccab12..4eccd25 100644
a
|
b
|
VIDEO; |
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
| 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 | /** |
727 | 764 | * Test [video] shortcode processing |
728 | 765 | * |
729 | 766 | */ |