diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
index e2c8aef269..be27b07ca6 100644
--- a/src/wp-includes/formatting.php
+++ b/src/wp-includes/formatting.php
@@ -580,7 +580,7 @@ function wpautop( $pee, $br = true ) {
// Optionally insert line breaks.
if ( $br ) {
// Replace newlines that shouldn't be touched with a placeholder.
- $pee = preg_replace_callback( '/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee );
+ $pee = preg_replace_callback( '/<(script|style|svg).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee );
// Normalize
$pee = str_replace( array( '
', '
' ), '
', $pee );
diff --git a/tests/phpunit/tests/formatting/Autop.php b/tests/phpunit/tests/formatting/Autop.php
index 405b68ad34..e93e826695 100644
--- a/tests/phpunit/tests/formatting/Autop.php
+++ b/tests/phpunit/tests/formatting/Autop.php
@@ -566,4 +566,38 @@ line 2
$this->assertEquals( $expected, trim( wpautop( $content ) ) );
}
+
+ /**
+ * wpautop() should ignore inline SVG graphics
+ *
+ * @ticket 9437
+ */
+ function test_that_wpautop_ignores_inline_svgs() {
+ $content =
+ '';
+
+ $expected = '
' . $content . '
'; + + $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + } + + /** + * wpautop() should ignore inline scripts + * + * @ticket 9437 + */ + function test_that_wpautop_ignores_inline_scripts() { + $content = + ''; + + $expected = '' . $content . '
'; + + $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + } }