Make WordPress Core


Ignore:
Timestamp:
06/26/2014 05:14:47 PM (11 years ago)
Author:
wonderboymusic
Message:

Use less greedy regex in wptexturize(). Adds unit tests.

Props miqrogroove.
See #28564.

File:
1 edited

Legend:

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

    r28831 r28852  
    199199        .       '.+?--\s*>' // Find end of comment
    200200        .   '|'
    201         .       '.+?>'      // Find end of element
     201        .       '[^>]+>'    // Find end of element
    202202        .   ')'
    203203        . '|'
     
    207207        .       '[^\[\]<>]' // Shortcodes do not contain other shortcodes.
    208208        .   '|'
    209         .       '<.+?>'     // HTML elements permitted. Prevents matching ] before >.
     209        .       '<[^>]+>'   // HTML elements permitted. Prevents matching ] before >.
    210210        .   ')+'
    211211        .   '\]'        // Find end of shortcode.
     
    225225            }
    226226
    227         } elseif ( '[' === $first && 1 === preg_match( '/^\[(?:[^\[\]<>]|<.+?>)+\]$/', $curl ) ) {
     227        } elseif ( '[' === $first && 1 === preg_match( '/^\[(?:[^\[\]<>]|<[^>]+>)+\]$/', $curl ) ) {
    228228            // This is a shortcode delimeter.
    229229
    230230            _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes );
    231231
    232         } elseif ( '[' === $first && 1 === preg_match( '/^\[\[?(?:[^\[\]<>]|<.+?>)+\]\]?$/', $curl ) ) {
     232        } elseif ( '[' === $first && 1 === preg_match( '/^\[\[?(?:[^\[\]<>]|<[^>]+>)+\]\]?$/', $curl ) ) {
    233233            // This is an escaped shortcode delimeter.
    234234
Note: See TracChangeset for help on using the changeset viewer.