Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php	(revision 16340)
+++ wp-includes/post-template.php	(working copy)
@@ -165,7 +165,7 @@
 function the_content($more_link_text = null, $stripteaser = 0) {
 	$content = get_the_content($more_link_text, $stripteaser);
 	$content = apply_filters('the_content', $content);
-	$content = str_replace(']]>', ']]&gt;', $content);
+	$content = escape_cdata_close( $content );
 	echo $content;
 }
 
Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 16336)
+++ wp-includes/comment.php	(working copy)
@@ -1688,7 +1688,7 @@
 		$excerpt = apply_filters('the_content', $post->post_content);
 	else
 		$excerpt = apply_filters('the_excerpt', $post->post_excerpt);
-	$excerpt = str_replace(']]>', ']]&gt;', $excerpt);
+	$excerpt = escape_cdata_close( $excerpt );
 	$excerpt = wp_html_excerpt($excerpt, 252) . '...';
 
 	$post_title = apply_filters('the_title', $post->post_title);
Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 16340)
+++ wp-includes/formatting.php	(working copy)
@@ -1881,7 +1881,7 @@
 		$text = strip_shortcodes( $text );
 
 		$text = apply_filters('the_content', $text);
-		$text = str_replace(']]>', ']]&gt;', $text);
+		$text = escape_cdata_close( $text );
 		$text = strip_tags($text);
 		$excerpt_length = apply_filters('excerpt_length', 55);
 		$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
@@ -2906,4 +2906,17 @@
 
 }
 
-?>
+/**
+ * Escapes closing CDATA block by splitting the closing tag between two sections.
+ *
+ * @since 3.1.0
+ * @link http://core.trac.wordpress.org/ticket/3670
+ *
+ * @param string $str String with CDATA block to escape
+ * @return string String with CDATA block escaped
+ */
+function escape_cdata_close( $str ) {
+	return '<![CDATA[' . str_replace( ']]>', ']]]><![CDATA[]>', $str ) . ']]>';
+}
+
+?>
\ No newline at end of file
Index: wp-includes/deprecated.php
===================================================================
--- wp-includes/deprecated.php	(revision 16336)
+++ wp-includes/deprecated.php	(working copy)
@@ -1734,7 +1734,7 @@
 		$excerpt .= ($use_dotdotdot) ? '...' : '';
 		$content = $excerpt;
 	}
-	$content = str_replace(']]>', ']]&gt;', $content);
+	$content = escape_cdata_close( $content );
 	echo $content;
 }
 
Index: wp-includes/feed.php
===================================================================
--- wp-includes/feed.php	(revision 16336)
+++ wp-includes/feed.php	(working copy)
@@ -145,7 +145,7 @@
 		$feed_type = get_default_feed();
 
 	$content = apply_filters('the_content', get_the_content());
-	$content = str_replace(']]>', ']]&gt;', $content);
+	$content = escape_cdata_close( $content );
 	return apply_filters('the_content_feed', $content, $feed_type);
 }
 
