Make WordPress Core


Ignore:
Timestamp:
06/10/2014 01:54:11 AM (11 years ago)
Author:
wonderboymusic
Message:

Ensure that shortcode_unautop() treats   like whitespace.
shortcode_unautop() and wptexturize() now use wp_spaces_regexp() instead of raw regex.

Adds unit tests.

Props miqrogroove.
See #27588.

File:
1 edited

Legend:

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

    r28715 r28716  
    8383        $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );
    8484
    85         /*
    86          * Regex for common whitespace characters.
    87          *
    88          * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp.
    89          * This is designed to replace the PCRE \s sequence.  In #WP22692, that sequence
    90          * was found to be unreliable due to random inclusion of the A0 byte.
    91          */
    92         $spaces = '[\r\n\t ]|\xC2\xA0| ';
     85        $spaces = wp_spaces_regexp();
    9386
    9487
     
    371364
    372365    $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
     366    $spaces = wp_spaces_regexp();
    373367
    374368    $pattern =
    375369          '/'
    376370        . '<p>'                              // Opening paragraph
    377         . '\\s*+'                            // Optional leading whitespace
     371        . '(?:' . $spaces . ')*+'            // Optional leading whitespace
    378372        . '('                                // 1: The shortcode
    379373        .     '\\['                          // Opening bracket
     
    400394        .     ')'
    401395        . ')'
    402         . '\\s*+'                            // optional trailing whitespace
     396        . '(?:' . $spaces . ')*+'            // optional trailing whitespace
    403397        . '<\\/p>'                           // closing paragraph
    404398        . '/s';
     
    38583852
    38593853    if ( empty( $spaces ) ) {
     3854        /**
     3855         * Regexp for common whitespace characters.
     3856         *
     3857         * This string is substituted for the \s sequence as needed in regular expressions.
     3858         * For websites not written in English, different characters may represent whitespace.
     3859         * For websites not encoded in UTF-8, the 0xC2 0xA0 sequence may not be in use.
     3860         *
     3861         * @since 4.0.0
     3862         *
     3863         * @param string $spaces
     3864         */
    38603865        $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0|&nbsp;' );
    38613866    }
Note: See TracChangeset for help on using the changeset viewer.