Make WordPress Core


Ignore:
Timestamp:
07/30/2015 07:40:33 PM (11 years ago)
Author:
azaozz
Message:

Backport r33469 and r33470 to 4.2.
See #33106.

File:
1 edited

Legend:

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

    r33499 r33518  
    329329   
    330330    $pattern = get_shortcode_regex();
    331 
    332     $comment_regex =
    333           '!'           // Start of comment, after the <.
    334         . '(?:'         // Unroll the loop: Consume everything until --> is found.
    335         .     '-(?!->)' // Dash not followed by end of comment.
    336         .     '[^\-]*+' // Consume non-dashes.
    337         . ')*+'         // Loop possessively.
    338         . '(?:-->)?';   // End of comment. If not found, match all input.
    339 
    340     $regex =
    341           '/('                   // Capture the entire match.
    342         .     '<'                // Find start of element.
    343         .     '(?(?=!--)'        // Is this a comment?
    344         .         $comment_regex // Find end of comment.
    345         .     '|'
    346         .         '[^>]*>?'      // Find end of element. If not found, match all input.
    347         .     ')'
    348         . ')/s';
    349 
    350     $textarr = preg_split( $regex, $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     331    $textarr = wp_html_split( $content );
    351332
    352333    foreach ( $textarr as &$element ) {
    353         if ( '<' !== $element[0] ) {
     334        if ( '' == $element || '<' !== $element[0] ) {
    354335            continue;
    355336        }
     
    366347        }
    367348
    368         if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) ) {
     349        if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) || '<![CDATA[' === substr( $element, 0, 9 ) ) {
    369350            // Encode all [ and ] chars.
    370351            $element = strtr( $element, $trans );
Note: See TracChangeset for help on using the changeset viewer.