WordPress.org

Make WordPress Core

Ticket #3670: 3670.2.diff

File 3670.2.diff, 2.8 KB (added by ryan, 4 years ago)

Escape cdata close via filter on the_content

  • wp-includes/default-filters.php

     
    110110add_filter( 'the_content', 'wpautop'            ); 
    111111add_filter( 'the_content', 'shortcode_unautop'  ); 
    112112add_filter( 'the_content', 'prepend_attachment' ); 
     113add_filter( 'the_content', '_escape_cdata_close', 20); 
    113114 
    114115add_filter( 'the_excerpt',     'wptexturize'      ); 
    115116add_filter( 'the_excerpt',     'convert_smilies'  ); 
  • wp-includes/post-template.php

     
    164164function the_content($more_link_text = null, $stripteaser = 0) { 
    165165        $content = get_the_content($more_link_text, $stripteaser); 
    166166        $content = apply_filters('the_content', $content); 
    167         $content = str_replace(']]>', ']]>', $content); 
    168167        echo $content; 
    169168} 
    170169 
  • wp-includes/comment.php

     
    15661566                return; 
    15671567        } 
    15681568 
    1569         if ( empty($post->post_excerpt) ) 
     1569        if ( empty($post->post_excerpt) ) { 
    15701570                $excerpt = apply_filters('the_content', $post->post_content); 
    1571         else 
     1571        } else { 
    15721572                $excerpt = apply_filters('the_excerpt', $post->post_excerpt); 
    1573         $excerpt = str_replace(']]>', ']]>', $excerpt); 
     1573                $excerpt = str_replace(']]>', ']]>', $excerpt); 
     1574        } 
    15741575        $excerpt = wp_html_excerpt($excerpt, 252) . '...'; 
    15751576 
    15761577        $post_title = apply_filters('the_title', $post->post_title); 
  • wp-includes/formatting.php

     
    18071807                $text = strip_shortcodes( $text ); 
    18081808 
    18091809                $text = apply_filters('the_content', $text); 
    1810                 $text = str_replace(']]>', ']]>', $text); 
    18111810                $text = strip_tags($text); 
    18121811                $excerpt_length = apply_filters('excerpt_length', 55); 
    18131812                $excerpt_more = apply_filters('excerpt_more', '[...]'); 
     
    28462845        return apply_filters('sanitize_text_field', $filtered, $str); 
    28472846} 
    28482847 
     2848function _escape_cdata_close($content) { 
     2849        return str_replace(']]>', ']]>', $content); 
     2850} 
     2851 
    28492852?> 
  • wp-includes/feed.php

     
    145145                $feed_type = get_default_feed(); 
    146146 
    147147        $content = apply_filters('the_content', get_the_content()); 
    148         $content = str_replace(']]>', ']]>', $content); 
    149148        return apply_filters('the_content_feed', $content, $feed_type); 
    150149} 
    151150