diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index ed87b2b8ad..71f1794c52 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -3568,6 +3568,10 @@ function normalize_whitespace( $str ) { /** * Properly strip all HTML tags including script and style + * + * This differs from strip_tags() because it removes the contents of + * the ' ) + * will return 'something'. wp_strip_all_tags will return '' * * @since 2.9.0 * diff --git a/tests/phpunit/tests/formatting/WPStripAllTags.php b/tests/phpunit/tests/formatting/WPStripAllTags.php new file mode 100644 index 0000000000..3af07b5709 --- /dev/null +++ b/tests/phpunit/tests/formatting/WPStripAllTags.php @@ -0,0 +1,33 @@ +ipsum'; + $this->assertEquals( 'loremipsum', wp_strip_all_tags( $text ) ); + + $text = "lorem
\nipsum"; + $this->assertEquals( "lorem\nipsum", wp_strip_all_tags( $text ) ); + + // test removing breaks is working + $text = "lorem
ipsum"; + $this->assertEquals( "loremipsum", wp_strip_all_tags( $text, true ) ); + + // test script / style tag's contents is removed + $text = "loremipsum"; + $this->assertEquals( "loremipsum", wp_strip_all_tags( $text ) ); + + $text = "loremipsum"; + $this->assertEquals( "loremipsum", wp_strip_all_tags( $text ) ); + + // test "marlformed" markup of contents + $text = "loremipsum"; + $this->assertEquals( "loremipsum", wp_strip_all_tags( $text ) ); + } +} +