Преглед изворни кода

FIX html detection fails if only u tag is present

Laurent Destailleur пре 9 година
родитељ
комит
b615b52f47
2 измењених фајлова са 16 додато и 13 уклоњено
  1. 1 1
      htdocs/core/lib/functions.lib.php
  2. 15 12
      test/phpunit/FunctionsLibTest.php

+ 1 - 1
htdocs/core/lib/functions.lib.php

@@ -4548,7 +4548,7 @@ function dol_textishtml($msg,$option=0)
 	{
 		if (preg_match('/<html/i',$msg))				return true;
 		elseif (preg_match('/<body/i',$msg))			return true;
-		elseif (preg_match('/<(b|em|i)>/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;

+ 15 - 12
test/phpunit/FunctionsLibTest.php

@@ -206,40 +206,43 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
         // True
         $input='<html>xxx</html>';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with html tag');
         $input='<body>xxx</body>';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with body tag');
         $input='xxx <b>yyy</b> zzz';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with b tag');
+        $input='xxx <u>yyy</u> zzz';
+        $after=dol_textishtml($input);
+        $this->assertTrue($after, 'Test with u tag');
         $input='text with <div>some div</div>';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with div tag');
         $input='text with HTML &nbsp; entities';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with entities tag');
         $input='xxx<br>';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with entities br');
         $input='xxx<br >';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with entities br');
         $input='xxx<br style="eee">';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with entities br and attributes');
         $input='xxx<br style="eee" >';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with entities br and attributes bis');
         $input='<h2>abc</h2>';
         $after=dol_textishtml($input);
-        $this->assertTrue($after);
+        $this->assertTrue($after, 'Test with entities h2');
         $input='<img id="abc" src="https://xxx.com/aaa/image.png" />';
         $after=dol_textishtml($input);
-        $this->assertTrue($after,'Failure on test of img tag');
+        $this->assertTrue($after, 'Test with img tag');
         $input='<a class="azerty" href="https://xxx.com/aaa/image.png" />';
         $after=dol_textishtml($input);
-        $this->assertTrue($after,'Failure on test of a tag');
+        $this->assertTrue($after, 'Test with a tag');
 
         // False
         $input='xxx < br>';