diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2ae90c1f0b5..54658f531c7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4548,7 +4548,7 @@ function dol_textishtml($msg,$option=0) { if (preg_match('//i',$msg)) return true; + elseif (preg_match('/<(b|em|i|u)>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true; diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 79bcc931c84..4c76ba47770 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -206,40 +206,43 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase // True $input='xxx'; $after=dol_textishtml($input); - $this->assertTrue($after); + $this->assertTrue($after, 'Test with html tag'); $input='
xxx'; $after=dol_textishtml($input); - $this->assertTrue($after); + $this->assertTrue($after, 'Test with body tag'); $input='xxx yyy zzz'; $after=dol_textishtml($input); - $this->assertTrue($after); + $this->assertTrue($after, 'Test with b tag'); + $input='xxx yyy zzz'; + $after=dol_textishtml($input); + $this->assertTrue($after, 'Test with u tag'); $input='text with
';
$after=dol_textishtml($input);
- $this->assertTrue($after,'Failure on test of img tag');
+ $this->assertTrue($after, 'Test with img tag');
$input='';
$after=dol_textishtml($input);
- $this->assertTrue($after,'Failure on test of a tag');
+ $this->assertTrue($after, 'Test with a tag');
// False
$input='xxx < br>';