forked from Wavyzz/dolibarr
Fix dol_string_nohtmltag: the decode of entity must be done before split
This commit is contained in:
@@ -5486,23 +5486,24 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
|
||||
if ($removelinefeed == 2) $stringtoclean = preg_replace('/<br[^>]*>(\n|\r)+/ims', '<br>', $stringtoclean);
|
||||
$temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
|
||||
|
||||
// We remove entities BEFORE stripping (in case of a separator char is encoded and not the other, the strip will fails)
|
||||
$temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
|
||||
|
||||
if ($strip_tags) {
|
||||
$temp = strip_tags($temp);
|
||||
} else {
|
||||
$pattern = "/<[^<>]+>/";
|
||||
// Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
|
||||
// Example 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
|
||||
}
|
||||
|
||||
$temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
|
||||
|
||||
// Supprime aussi les retours
|
||||
// Remove also CR LF
|
||||
if ($removelinefeed == 1) $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
|
||||
|
||||
// et les espaces doubles
|
||||
// and double spaces
|
||||
while (strpos($temp, " "))
|
||||
{
|
||||
$temp = str_replace(" ", " ", $temp);
|
||||
|
||||
Reference in New Issue
Block a user