From a7e581d991c1e149552110b68b4721ca3c28edf8 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 11 Feb 2015 19:15:26 +0000 Subject: [PATCH] After [31415], make sure `str_replace()` only occurs once for each matched tag to avoid overwriting until `
`s.

See #31214.

Built from https://develop.svn.wordpress.org/trunk@31416


git-svn-id: http://core.svn.wordpress.org/trunk@31397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
 wp-includes/class-oembed.php | 5 ++++-
 wp-includes/version.php      | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/wp-includes/class-oembed.php b/wp-includes/class-oembed.php
index 8891d2e2a9..8f8bccab79 100644
--- a/wp-includes/class-oembed.php
+++ b/wp-includes/class-oembed.php
@@ -568,6 +568,8 @@ class WP_oEmbed {
 		if ( class_exists( 'DOMDocument' ) ) {
 			$token = '__PRE__';
 			$replace = array();
+			$count = 1;
+
 			$dom = new DOMDocument();
 			$dom->loadHTML( $html );
 			$tags = $dom->getElementsByTagName( 'pre' );
@@ -575,7 +577,8 @@ class WP_oEmbed {
 				$tag_html = $dom->saveHTML( $tag );
 				$tag_token = $token . $i;
 				$replace[ $tag_token ] = $tag_html;
-				$html = str_replace( $tag_html, $tag_token, $html );
+
+				$html = str_replace( $tag_html, $tag_token, $html, $count );
 			}
 			$pre = array_values( $replace );
 			$tokens = array_keys( $replace );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 37bd8283ca..3947059c00 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -4,7 +4,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '4.2-alpha-31415';
+$wp_version = '4.2-alpha-31416';
 
 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.