diff --git a/core/Convert.php b/core/Convert.php index c888b5c49..c2c0c01a9 100755 --- a/core/Convert.php +++ b/core/Convert.php @@ -264,14 +264,11 @@ class Convert { $data = preg_replace("/][^>]*)?>.*?<\/style[^>]*>/i","", $data); $data = preg_replace("/][^>]*)?>.*?<\/script[^>]*>/i","", $data); - // TODO Deal with attributes inside tags + if($config['ReplaceBoldAsterisk']) { - $data = str_ireplace( - array('','','',''), - '*', - $data - ); + $data = preg_replace('%<(strong|b)( [^>]*)?>|%i','*',$data); } + // Expand hyperlinks if(!$preserveLinks && !$config['PreserveLinks']) { $data = preg_replace('/]*href\s*=\s*"([^"]*)">(.*?)<\/a>/ie', "Convert::html2raw('\\2').'[\\1]'", $data); diff --git a/tests/ConvertTest.php b/tests/ConvertTest.php index e4e0e5c44..dca24fad9 100644 --- a/tests/ConvertTest.php +++ b/tests/ConvertTest.php @@ -28,6 +28,19 @@ class ConvertTest extends SapphireTest { $this->assertEquals('Thisissomenormaltext', Convert::raw2htmlatt($val2), 'Normal text is not escaped'); } + function testHtml2raw() { + $val1 = 'This has a strong tag.'; + $this->assertEquals('This has a *strong tag*.', Convert::xml2raw($val1), 'Strong tags are replaced with asterisks'); + + $val1 = 'This has a b tag with attributes.'; + $this->assertEquals('This has a *b tag with attributes*.', Convert::xml2raw($val1), 'B tags with attributes are replaced with asterisks'); + + $val2 = 'This has a strong tag with attributes.'; + $this->assertEquals('This has a *strong tag with attributes*.', Convert::xml2raw($val2), 'Strong tags with attributes are replaced with asterisks'); + + + } + /** * Tests {@link Convert::raw2xml()} */