WordPress.org

Make WordPress Core

Changeset 37298


Ignore:
Timestamp:
04/22/2016 07:07:03 AM (4 years ago)
Author:
pento
Message:

Smilies: Move convert_smilies to happen later in the the_content filter.

In particular, we want it to occur after shortcode handling. The smiley conversion routine doesn't have any concept of shortcode structure, so may inadvertantly replace a smiley with HTML inside a shortcode attribute, which will cause the shortcode to not be parsed correctly.

Props Unyson for the initial suggested fix.

Fixes #36306.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r36915 r37298  
    131131
    132132add_filter( 'the_content', 'wptexturize'                       );
    133 add_filter( 'the_content', 'convert_smilies'                  );
     133add_filter( 'the_content', 'convert_smilies',               20 );
    134134add_filter( 'the_content', 'wpautop'                           );
    135135add_filter( 'the_content', 'shortcode_unautop'                 );
  • trunk/tests/phpunit/tests/shortcode.php

    r36099 r37298  
    55class Tests_Shortcode extends WP_UnitTestCase {
    66
    7     protected $shortcodes = array( 'test-shortcode-tag', 'footag', 'bartag', 'baztag', 'dumptag', 'hyphen', 'hyphen-foo', 'hyphen-foo-bar', 'url' );
     7    protected $shortcodes = array( 'test-shortcode-tag', 'footag', 'bartag', 'baztag', 'dumptag', 'hyphen', 'hyphen-foo', 'hyphen-foo-bar', 'url', 'img' );
    88
    99    function setUp() {
     
    7777    function _shortcode_url() {
    7878        return 'http://www.wordpress.org/';
     79    }
     80
     81    function _shortcode_img( $atts ) {
     82        $out = '<img';
     83        foreach ( $atts as $k => $v ) {
     84            $out .= " $k=\"$v\"";
     85        }
     86        $out .= ' />';
     87
     88        return $out;
    7989    }
    8090
     
    658668        $this->assertEquals($expected, $out);
    659669    }
     670
     671    /**
     672     * @ticket 36306
     673     */
     674    function test_smilies_arent_converted() {
     675        $out = apply_filters( 'the_content', '[img alt="Hello :-) World"]' );
     676        $expected = "<img alt=\"Hello :-) World\" />\n";
     677        $this->assertEquals( $expected, $out );
     678    }
    660679}
Note: See TracChangeset for help on using the changeset viewer.