diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 707586e23..30d424faf 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -162,7 +162,7 @@ class Sanitize { $str = $params[0]; for ($i = 1; $i < count($params); $i++) { - $str = preg_replace('/<' . $params[$i] . '[^>]*>/i', '', $str); + $str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str); $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str); } return $str; diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php index c62e9c965..31101445e 100644 --- a/cake/tests/cases/libs/sanitize.test.php +++ b/cake/tests/cases/libs/sanitize.test.php @@ -375,6 +375,26 @@ class SanitizeTest extends CakeTestCase { $expected = 'Important
Additional information here . Read even more here
'; $result = Sanitize::stripTags($string, 'h2', 'a'); $this->assertEqual($result, $expected); + + $string = 'Additional information here . Read even more here
'; + $expected = 'ImportantAdditional information here . Read even more here
'; + $result = Sanitize::stripTags($string, 'h2', 'a', 'img'); + $this->assertEqual($result, $expected); + + $string = 'Important message!Additional information here . Read even more here
'; + $expected = 'ImportantAdditional information here . Read even more here
'; + $result = Sanitize::stripTags($string, 'h2', 'a', 'img'); + $this->assertEqual($result, $expected); } /** * testFormatColumns method