WordPress.org

Make WordPress Core

Ticket #3670: 3670.3.diff

File 3670.3.diff, 2.9 KB (added by nacin, 10 years ago)

Introduce escape_cdata_close()

  • wp-includes/post-template.php

     
    165165function the_content($more_link_text = null, $stripteaser = 0) {
    166166        $content = get_the_content($more_link_text, $stripteaser);
    167167        $content = apply_filters('the_content', $content);
    168         $content = str_replace(']]>', ']]>', $content);
     168        $content = escape_cdata_close( $content );
    169169        echo $content;
    170170}
    171171
  • wp-includes/comment.php

     
    16881688                $excerpt = apply_filters('the_content', $post->post_content);
    16891689        else
    16901690                $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    1691         $excerpt = str_replace(']]>', ']]>', $excerpt);
     1691        $excerpt = escape_cdata_close( $excerpt );
    16921692        $excerpt = wp_html_excerpt($excerpt, 252) . '...';
    16931693
    16941694        $post_title = apply_filters('the_title', $post->post_title);
  • wp-includes/formatting.php

     
    18811881                $text = strip_shortcodes( $text );
    18821882
    18831883                $text = apply_filters('the_content', $text);
    1884                 $text = str_replace(']]>', ']]>', $text);
     1884                $text = escape_cdata_close( $text );
    18851885                $text = strip_tags($text);
    18861886                $excerpt_length = apply_filters('excerpt_length', 55);
    18871887                $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
     
    29062906
    29072907}
    29082908
    2909 ?>
     2909/**
     2910 * Escapes closing CDATA block by splitting the closing tag between two sections.
     2911 *
     2912 * @since 3.1.0
     2913 * @link http://core.trac.wordpress.org/ticket/3670
     2914 *
     2915 * @param string $str String with CDATA block to escape
     2916 * @return string String with CDATA block escaped
     2917 */
     2918function escape_cdata_close( $str ) {
     2919        return '<![CDATA[' . str_replace( ']]>', ']]]><![CDATA[]>', $str ) . ']]>';
     2920}
     2921
     2922?>
     2923 No newline at end of file
  • wp-includes/deprecated.php

     
    17341734                $excerpt .= ($use_dotdotdot) ? '...' : '';
    17351735                $content = $excerpt;
    17361736        }
    1737         $content = str_replace(']]>', ']]&gt;', $content);
     1737        $content = escape_cdata_close( $content );
    17381738        echo $content;
    17391739}
    17401740
  • wp-includes/feed.php

     
    145145                $feed_type = get_default_feed();
    146146
    147147        $content = apply_filters('the_content', get_the_content());
    148         $content = str_replace(']]>', ']]&gt;', $content);
     148        $content = escape_cdata_close( $content );
    149149        return apply_filters('the_content_feed', $content, $feed_type);
    150150}
    151151