Skip to content

Commit

Permalink
After [31415], make sure str_replace() only occurs once for each ma…
Browse files Browse the repository at this point in the history
…tched tag to avoid overwriting until `<pre>`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
  • Loading branch information
staylor committed Feb 11, 2015
1 parent cb3ef90 commit a7e581d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion wp-includes/class-oembed.php
Expand Up @@ -568,14 +568,17 @@ public function _strip_newlines( $html, $data, $url ) {
if ( class_exists( 'DOMDocument' ) ) {
$token = '__PRE__';
$replace = array();
$count = 1;

$dom = new DOMDocument();
$dom->loadHTML( $html );
$tags = $dom->getElementsByTagName( 'pre' );
foreach ( $tags as $i => $tag ) {
$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 );
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -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.
Expand Down

0 comments on commit a7e581d

Please sign in to comment.