Make WordPress Core

Ticket #29557: 29557-idea-2.diff

File 29557-idea-2.diff, 3.0 KB (added by miqrogroove, 10 years ago)

Idea 2: Break Jetpack. Go back to filtering shortcode names.

  • src/wp-includes/formatting.php

     
    2828 * @return string The string replaced with html entities
    2929 */
    3030function wptexturize($text, $reset = false) {
    31         global $wp_cockneyreplace;
     31        global $wp_cockneyreplace, $shortcode_tags;
    3232        static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,
    3333                $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true;
    3434
     
    205205
    206206        // Look for shortcodes and HTML elements.
    207207
     208        $tagnames = array_keys( $shortcode_tags );
     209        $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
     210        $tagregexp = "(?:$tagregexp)(?![\\w-])"; // Excerpt of get_shortcode_regex().
     211
    208212        $comment_regex =
    209213                  '!'           // Start of comment, after the <.
    210214                . '(?:'         // Unroll the loop: Consume everything until --> is found.
     
    216220        $shortcode_regex =
    217221                  '\['          // Find start of shortcode.
    218222                . '[\/\[]?'     // Shortcodes may begin with [/ or [[
    219                 . '[^\s\/\[\]]' // No whitespace before name.
     223                . $tagregexp    // Only match registered shortcodes.
    220224                . '[^\[\]]*+'   // Shortcodes do not contain other shortcodes. Possessive critical.
    221225                . '\]'          // Find end of shortcode.
    222226                . '\]?';        // Shortcodes may end with ]]
  • tests/phpunit/tests/formatting/WPTexturize.php

     
    11971197                        ),
    11981198                        array(
    11991199                                '[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', // HTML corruption is a known bug.  See tickets #12690 and #29557.
    1200                                 '[is it wise to <a title="allow user content ] here? hmm&#8221;> maybe </a> ]',
     1200                                '[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
    12011201                        ),
    12021202                        array(
    12031203                                '[caption - is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]',
     
    17671767                        ),
    17681768                        array(
    17691769                                '[code ...]...[/code]', // code is not a registered shortcode.
    1770                                 '[code ...]...[/code]',
     1770                                '[code &#8230;]&#8230;[/code]',
    17711771                        ),
    17721772                        array(
    17731773                                '[hello ...]...[/hello]', // hello is not a registered shortcode.
    1774                                 '[hello ...]&#8230;[/hello]',
     1774                                '[hello &#8230;]&#8230;[/hello]',
    17751775                        ),
    17761776                        array(
    17771777                                '[...]...[/...]', // These are potentially usable shortcodes.
    1778                                 '[...]&#8230;[/...]',
     1778                                '[&#8230;]&#8230;[/&#8230;]',
    17791779                        ),
    17801780                        array(
    17811781                                '[gal>ery ...]',
    1782                                 '[gal>ery ...]',
     1782                                '[gal>ery &#8230;]',
    17831783                        ),
    17841784                        array(
    17851785                                '[randomthing param="test"]',
    1786                                 '[randomthing param="test"]',
     1786                                '[randomthing param=&#8221;test&#8221;]',
    17871787                        ),
    17881788                        array(
    17891789                                '[[audio]...[/audio]...', // These are potentially usable shortcodes.  Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp.