Make WordPress Core


Ignore:
Timestamp:
07/23/2015 05:14:09 AM (10 years ago)
Author:
pento
Message:

Shortcodes: Improve the reliablity of shortcodes inside HTML tags.

Merge of [33359] to the 3.7 branch.

Props miqrogroove.

See #15694.

File:
1 edited

Legend:

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

    r32151 r33389  
    374374    }
    375375
     376    /**
     377     * Check for bugginess using normal input with latest patches.
     378     *
     379     * @dataProvider data_escaping
     380     */
     381    function test_escaping( $input, $output ) {
     382        return $this->assertEquals( $output, do_shortcode( $input ) );
     383    }
     384
     385    function data_escaping() {
     386        return array(
     387            array(
     388                '<!--[if lt IE 7]>',
     389                '<!--[if lt IE 7]>',
     390            ),
     391            array(
     392                '[gallery title="<div>hello</div>"]',
     393                '',
     394            ),
     395            array(
     396                '[caption caption="test" width="2"]<div>hello</div>[/caption]',
     397                '<div style="width: 12px" class="wp-caption alignnone"><div>hello</div><p class="wp-caption-text">test</p></div>',
     398            ),
     399            array(
     400                '<div [gallery]>',
     401                '<div >',
     402            ),
     403            array(
     404                '<div [[gallery]]>',
     405                '<div [gallery]>',
     406            ),
     407            array(
     408                '[gallery]<div>Hello</div>[/gallery]',
     409                '',
     410            ),
     411        );
     412    }
     413
     414    /**
     415     * Check for bugginess using normal input with latest patches.
     416     *
     417     * @dataProvider data_escaping2
     418     */
     419    function test_escaping2( $input, $output ) {
     420        return $this->assertEquals( $output, strip_shortcodes( $input ) );
     421    }
     422
     423    function data_escaping2() {
     424        return array(
     425            array(
     426                '<!--[if lt IE 7]>',
     427                '<!--[if lt IE 7]>',
     428            ),
     429            array(
     430                '[gallery title="<div>hello</div>"]',
     431                '',
     432            ),
     433            array(
     434                '[caption caption="test" width="2"]<div>hello</div>[/caption]',
     435                '',
     436            ),
     437            array(
     438                '<div [gallery]>', // Shortcodes will never be stripped inside elements.
     439                '<div [gallery]>',
     440            ),
     441            array(
     442                '<div [[gallery]]>', // Shortcodes will never be stripped inside elements.
     443                '<div [[gallery]]>',
     444            ),
     445            array(
     446                '[gallery]<div>Hello</div>[/gallery]',
     447                '',
     448            ),
     449        );
     450    }
     451
    376452}
Note: See TracChangeset for help on using the changeset viewer.