WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/31/2015 01:45:34 AM (6 years ago)
Author:
azaozz
Message:

Backport r33469 and r33470 to 3.7.
See #33106.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7/src/wp-includes/shortcodes.php

    r33389 r33525  
    320320   
    321321    $pattern = get_shortcode_regex();
    322 
    323     $comment_regex =
    324           '!'           // Start of comment, after the <.
    325         . '(?:'         // Unroll the loop: Consume everything until --> is found.
    326         .     '-(?!->)' // Dash not followed by end of comment.
    327         .     '[^\-]*+' // Consume non-dashes.
    328         . ')*+'         // Loop possessively.
    329         . '(?:-->)?';   // End of comment. If not found, match all input.
    330 
    331     $regex =
    332           '/('                   // Capture the entire match.
    333         .     '<'                // Find start of element.
    334         .     '(?(?=!--)'        // Is this a comment?
    335         .         $comment_regex // Find end of comment.
    336         .     '|'
    337         .         '[^>]*>?'      // Find end of element. If not found, match all input.
    338         .     ')'
    339         . ')/s';
    340 
    341     $textarr = preg_split( $regex, $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     322    $textarr = wp_html_split( $content );
    342323
    343324    foreach ( $textarr as &$element ) {
    344         if ( '<' !== $element[0] ) {
     325        if ( '' == $element || '<' !== $element[0] ) {
    345326            continue;
    346327        }
     
    357338        }
    358339
    359         if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) ) {
     340        if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) || '<![CDATA[' === substr( $element, 0, 9 ) ) {
    360341            // Encode all [ and ] chars.
    361342            $element = strtr( $element, $trans );
Note: See TracChangeset for help on using the changeset viewer.