Make WordPress Core


Ignore:
Timestamp:
07/31/2015 01:43:11 AM (10 years ago)
Author:
azaozz
Message:

Backport r33469 and r33470 to 4.0.
See #33106.

File:
1 edited

Legend:

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

    r33381 r33522  
    333333   
    334334    $pattern = get_shortcode_regex();
    335 
    336     $comment_regex =
    337           '!'           // Start of comment, after the <.
    338         . '(?:'         // Unroll the loop: Consume everything until --> is found.
    339         .     '-(?!->)' // Dash not followed by end of comment.
    340         .     '[^\-]*+' // Consume non-dashes.
    341         . ')*+'         // Loop possessively.
    342         . '(?:-->)?';   // End of comment. If not found, match all input.
    343 
    344     $regex =
    345           '/('                   // Capture the entire match.
    346         .     '<'                // Find start of element.
    347         .     '(?(?=!--)'        // Is this a comment?
    348         .         $comment_regex // Find end of comment.
    349         .     '|'
    350         .         '[^>]*>?'      // Find end of element. If not found, match all input.
    351         .     ')'
    352         . ')/s';
    353 
    354     $textarr = preg_split( $regex, $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     335    $textarr = wp_html_split( $content );
    355336
    356337    foreach ( $textarr as &$element ) {
    357         if ( '<' !== $element[0] ) {
     338        if ( '' == $element || '<' !== $element[0] ) {
    358339            continue;
    359340        }
     
    370351        }
    371352
    372         if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) ) {
     353        if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) || '<![CDATA[' === substr( $element, 0, 9 ) ) {
    373354            // Encode all [ and ] chars.
    374355            $element = strtr( $element, $trans );
Note: See TracChangeset for help on using the changeset viewer.