forked from Wavyzz/dolibarr
FIX dol_string_nohtmltag make 2 passes to clean html into html
attributes.
This commit is contained in:
@@ -4704,8 +4704,13 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
|
|||||||
$pattern = "/<[^<>]+>/";
|
$pattern = "/<[^<>]+>/";
|
||||||
$StringHtml = preg_replace('/<br[^>]*>/', "\n", $StringHtml);
|
$StringHtml = preg_replace('/<br[^>]*>/', "\n", $StringHtml);
|
||||||
$temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto);
|
$temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto);
|
||||||
$temp = preg_replace($pattern,"",$temp);
|
|
||||||
|
|
||||||
|
// Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
|
||||||
|
$temp = preg_replace($pattern,"",$temp); // pass 1
|
||||||
|
// $temp after pass 1: <a href="/myurl" title="A title">0000-021
|
||||||
|
$temp = preg_replace($pattern,"",$temp); // pass 2
|
||||||
|
// $temp after pass 2: 0000-021
|
||||||
|
|
||||||
// Supprime aussi les retours
|
// Supprime aussi les retours
|
||||||
if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp);
|
if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp);
|
||||||
|
|
||||||
|
|||||||
@@ -377,6 +377,14 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
|||||||
$after=dol_string_nohtmltag($text,1);
|
$after=dol_string_nohtmltag($text,1);
|
||||||
$this->assertEquals("A string Another string",$after,"test5");
|
$this->assertEquals("A string Another string",$after,"test5");
|
||||||
|
|
||||||
|
$text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
|
||||||
|
$after=dol_string_nohtmltag($text,1);
|
||||||
|
$this->assertEquals("ABC",$after,"test6");
|
||||||
|
|
||||||
|
$text='<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>';
|
||||||
|
$after=dol_string_nohtmltag($text,1);
|
||||||
|
$this->assertEquals("DEF",$after,"test7");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user