diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 74a28109b6536..c67a5be811c25 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -250,8 +250,18 @@ function wptexturize( $text, $reset = false ) { } else { // This is an HTML element delimiter. - // Replace each & with & unless it already looks like an entity. - $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl ); + /* + * Replace each & with & unless it already looks like an entity, + * but only when outside no-texturize tags like ', + wptexturize( '' ) + ); + $this->assertSame( + '', + wptexturize( '' ) + ); + $this->assertSame( + '
if(a', + wptexturize( 'if(a' ) + ); + $this->assertSame( + 'if(a', + wptexturize( 'if(a' ) + ); + // Ensure & in real HTML attributes is still encoded outside no-texturize tags. + $this->assertSame( + 'link', + wptexturize( 'link' ) + ); + } + /** * @ticket 1418 */