WordPress.org

Make WordPress Core

Ticket #3670: 3670-I.diff

File 3670-I.diff, 2.9 KB (added by andy, 8 years ago)

Remove incorrect entity encoding of ]]> and introduce cdata functions for filters.

  • 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);
    169168        echo $content;
    170169}
    171170
  • wp-includes/comment.php

     
    17101710                $excerpt = apply_filters('the_content', $post->post_content);
    17111711        else
    17121712                $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    1713         $excerpt = str_replace(']]>', ']]>', $excerpt);
    17141713        $excerpt = wp_html_excerpt($excerpt, 252) . '...';
    17151714
    17161715        $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);
    18851884                $text = strip_tags($text);
    18861885                $excerpt_length = apply_filters('excerpt_length', 55);
    18871886                $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
     
    29062905
    29072906}
    29082907
     2908/**
     2909 * Wrap a string in CDATA tags for inclusion of non-XML in XML.
     2910 *
     2911 * @since 3.2.0
     2912 */
     2913function wp_cdata( $string ) {
     2914        return '<![CDATA[' . wp_escape_cdata( $string ) . ']]>';
     2915}
     2916
     2917/**
     2918 * Make a string safe for inclusion in a CDATA block.
     2919 *
     2920 * The only invalid string in CDATA is "]]>". Since adjacent CDATA sections
     2921 * are equivalent to the result of their concatenation, the preferred method
     2922 * of including "]]>" is to split it between two sections.
     2923 *
     2924 * @since 3.2.0
     2925 */
     2926function wp_escape_cdata( $string ) {
     2927        return str_replace( ']]>', ']]]><![CDATA[]>', $string );
     2928}
     2929
    29092930?>
  • wp-includes/deprecated.php

     
    17341734                $excerpt .= ($use_dotdotdot) ? '...' : '';
    17351735                $content = $excerpt;
    17361736        }
    1737         $content = str_replace(']]>', ']]&gt;', $content);
    17381737        echo $content;
    17391738}
    17401739
  • 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);
    149148        return apply_filters('the_content_feed', $content, $feed_type);
    150149}
    151150