WordPress.org

Make WordPress Core

Ticket #35894: 35894.2.diff

File 35894.2.diff, 3.2 KB (added by swissspidy, 4 years ago)
  • src/wp-includes/embed.php

    diff --git src/wp-includes/embed.php src/wp-includes/embed.php
    index ff42351..8c79cc8 100644
    function wp_filter_oembed_result( $result, $data, $url ) { 
    777777
    778778        if ( ! empty( $content[1] ) ) {
    779779                // We have a blockquote to fall back on. Hide the iframe by default.
    780                 $html = str_replace( '<iframe', '<iframe style="display:none;"', $html );
     780                $html = str_replace( '<iframe', '<iframe style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', $html );
    781781                $html = str_replace( '<blockquote', '<blockquote class="wp-embedded-content"', $html );
    782782        }
    783783
    function print_embed_scripts() { 
    953953 * @return string The filtered content.
    954954 */
    955955function _oembed_filter_feed_content( $content ) {
    956         return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="display:none;"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content );
     956        return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content );
    957957}
    958958
    959959/**
  • src/wp-includes/js/wp-embed.js

    diff --git src/wp-includes/js/wp-embed.js src/wp-includes/js/wp-embed.js
    index 248ae2a..966a41f 100644
     
    5050                                continue;
    5151                        }
    5252
    53                         source.style.display = '';
     53                        source.removeAttribute( 'style' );
    5454
    5555                        /* Resize the iframe on request. */
    5656                        if ( 'height' === data.message ) {
  • tests/phpunit/tests/oembed/filterResult.php

    diff --git tests/phpunit/tests/oembed/filterResult.php tests/phpunit/tests/oembed/filterResult.php
    index 10dc43b..7f29d56 100644
    EOD; 
    8383                $html   = '<blockquote></blockquote><iframe></iframe>';
    8484                $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
    8585
    86                 $this->assertEquals( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="display:none;"></iframe>', $actual );
     86                $this->assertEquals( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual );
    8787        }
    8888
    8989        function test_filter_oembed_result_allowed_html() {
    9090                $html   = '<blockquote class="foo" id="bar"><strong><a href="" target=""></a></strong></blockquote><iframe></iframe>';
    9191                $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' );
    9292
    93                 $this->assertEquals( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="display:none;"></iframe>', $actual );
     93                $this->assertEquals( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual );
    9494        }
    9595
    9696        /**