Make WordPress Core


Ignore:
Timestamp:
07/23/2015 04:49:25 AM (10 years ago)
Author:
pento
Message:

Shortcodes: Improve the reliablity of shortcodes inside HTML tags.

Merge of [33359] to the 4.0 branch.

Props miqrogroove.

See #15694.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0/tests/phpunit/tests/shortcode.php

    r32148 r33381  
    397397
    398398    /**
     399     * Check for bugginess using normal input with latest patches.
     400     *
     401     * @dataProvider data_escaping
     402     */
     403    function test_escaping( $input, $output ) {
     404        return $this->assertEquals( $output, do_shortcode( $input ) );
     405    }
     406
     407    function data_escaping() {
     408        return array(
     409            array(
     410                '<!--[if lt IE 7]>',
     411                '<!--[if lt IE 7]>',
     412            ),
     413            array(
     414                '[gallery title="<div>hello</div>"]',
     415                '',
     416            ),
     417            array(
     418                '[caption caption="test" width="2"]<div>hello</div>[/caption]',
     419                '<div style="width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>',
     420            ),
     421            array(
     422                '<div [gallery]>',
     423                '<div >',
     424            ),
     425            array(
     426                '<div [[gallery]]>',
     427                '<div [gallery]>',
     428            ),
     429            array(
     430                '[gallery]<div>Hello</div>[/gallery]',
     431                '',
     432            ),
     433        );
     434    }
     435
     436    /**
     437     * Check for bugginess using normal input with latest patches.
     438     *
     439     * @dataProvider data_escaping2
     440     */
     441    function test_escaping2( $input, $output ) {
     442        return $this->assertEquals( $output, strip_shortcodes( $input ) );
     443    }
     444
     445    function data_escaping2() {
     446        return array(
     447            array(
     448                '<!--[if lt IE 7]>',
     449                '<!--[if lt IE 7]>',
     450            ),
     451            array(
     452                '[gallery title="<div>hello</div>"]',
     453                '',
     454            ),
     455            array(
     456                '[caption caption="test" width="2"]<div>hello</div>[/caption]',
     457                '',
     458            ),
     459            array(
     460                '<div [gallery]>', // Shortcodes will never be stripped inside elements.
     461                '<div [gallery]>',
     462            ),
     463            array(
     464                '<div [[gallery]]>', // Shortcodes will never be stripped inside elements.
     465                '<div [[gallery]]>',
     466            ),
     467            array(
     468                '[gallery]<div>Hello</div>[/gallery]',
     469                '',
     470            ),
     471        );
     472    }
     473
     474    /**
    399475     * @ticket 26343
    400476     */
Note: See TracChangeset for help on using the changeset viewer.