WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/10/2020 05:42:15 PM (14 months ago)
Author:
desrosj
Message:

Embeds: Ensure that the title attribute is set correctly on embeds.

Merges [47947] to the 5.4 branch.
Props xknown.

Location:
branches/5.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.4

  • branches/5.4/tests/phpunit/tests/oembed/filterResult.php

    r46586 r47953  
    9494    }
    9595
     96    public function _data_oembed_test_strings() {
     97        return array(
     98            array(
     99                '<blockquote></blockquote><iframe title=""></iframe>',
     100                '<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);" title="Hola"></iframe>',
     101            ),
     102            array(
     103                '<blockquote class="foo" id="bar"><strong><a href="" target=""></a></strong></blockquote><iframe width=123></iframe>',
     104                '<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);" title="Hola" width="123"></iframe>',
     105            ),
     106            array(
     107                '<blockquote><iframe width="100"></iframe></blockquote><iframe stitle="aaaa"></iframe>',
     108                '<blockquote class="wp-embedded-content"><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="Hola" width="100"></iframe></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="Hola"></iframe>',
     109            ),
     110            array(
     111                "<blockquote><iframe title=' width=\"'></iframe></blockquote><iframe title='' height=' title=' width=\"'' heigt='123'\"></iframe>",
     112                '<blockquote class="wp-embedded-content"><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title=" width=&quot;"></iframe></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title=" width=&quot;" height=\' title=\' width="\'\' heigt=\'123\'"></iframe>',
     113            ),
     114        );
     115    }
     116
     117    /**
     118     * @dataProvider _data_oembed_test_strings
     119     */
     120    public function test_wp_filter_pre_oembed_custom_result( $html, $expected ) {
     121        $data   = (object) array(
     122            'type'  => 'rich',
     123            'title' => 'Hola',
     124            'html'  => $html,
     125        );
     126        $actual = _wp_oembed_get_object()->data2html( $data, 'https://untrusted.localhost' );
     127        $this->assertEquals( $expected, $actual );
     128    }
     129
    96130    /**
    97131     * @group feed
Note: See TracChangeset for help on using the changeset viewer.