Ticket #3670: 3670.2.diff

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

Escape cdata close via filter on the_content

Line 
1Index: wp-includes/default-filters.php
2===================================================================
3--- wp-includes/default-filters.php     (revision 12407)
4+++ wp-includes/default-filters.php     (working copy)
5@@ -110,6 +110,7 @@
6 add_filter( 'the_content', 'wpautop'            );
7 add_filter( 'the_content', 'shortcode_unautop'  );
8 add_filter( 'the_content', 'prepend_attachment' );
9+add_filter( 'the_content', '_escape_cdata_close', 20);
10 
11 add_filter( 'the_excerpt',     'wptexturize'      );
12 add_filter( 'the_excerpt',     'convert_smilies'  );
13Index: wp-includes/post-template.php
14===================================================================
15--- wp-includes/post-template.php       (revision 12407)
16+++ wp-includes/post-template.php       (working copy)
17@@ -164,7 +164,6 @@
18 function the_content($more_link_text = null, $stripteaser = 0) {
19        $content = get_the_content($more_link_text, $stripteaser);
20        $content = apply_filters('the_content', $content);
21-       $content = str_replace(']]>', ']]>', $content);
22        echo $content;
23 }
24 
25Index: wp-includes/comment.php
26===================================================================
27--- wp-includes/comment.php     (revision 12407)
28+++ wp-includes/comment.php     (working copy)
29@@ -1566,11 +1566,12 @@
30                return;
31        }
32 
33-       if ( empty($post->post_excerpt) )
34+       if ( empty($post->post_excerpt) ) {
35                $excerpt = apply_filters('the_content', $post->post_content);
36-       else
37+       } else {
38                $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
39-       $excerpt = str_replace(']]>', ']]>', $excerpt);
40+               $excerpt = str_replace(']]>', ']]>', $excerpt);
41+       }
42        $excerpt = wp_html_excerpt($excerpt, 252) . '...';
43 
44        $post_title = apply_filters('the_title', $post->post_title);
45Index: wp-includes/formatting.php
46===================================================================
47--- wp-includes/formatting.php  (revision 12407)
48+++ wp-includes/formatting.php  (working copy)
49@@ -1807,7 +1807,6 @@
50                $text = strip_shortcodes( $text );
51 
52                $text = apply_filters('the_content', $text);
53-               $text = str_replace(']]>', ']]>', $text);
54                $text = strip_tags($text);
55                $excerpt_length = apply_filters('excerpt_length', 55);
56                $excerpt_more = apply_filters('excerpt_more', '[...]');
57@@ -2846,4 +2845,8 @@
58        return apply_filters('sanitize_text_field', $filtered, $str);
59 }
60 
61+function _escape_cdata_close($content) {
62+       return str_replace(']]>', ']]>', $content);
63+}
64+
65 ?>
66Index: wp-includes/feed.php
67===================================================================
68--- wp-includes/feed.php        (revision 12407)
69+++ wp-includes/feed.php        (working copy)
70@@ -145,7 +145,6 @@
71                $feed_type = get_default_feed();
72 
73        $content = apply_filters('the_content', get_the_content());
74-       $content = str_replace(']]>', ']]>', $content);
75        return apply_filters('the_content_feed', $content, $feed_type);
76 }
77