diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 9952af3841db6..92b594e58bf0c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4823,20 +4823,25 @@ function picto_required()
/**
- * Clean a string from all HTML tags and entities
+ * Clean a string from all HTML tags and entities.
+ * This function differs from strip_tags because:
+ * -
are replace with \n
+ * - if entities are found, they are decoded before the strip
+ * - you can decide to convert line feed into spaces
*
- * @param string $StringHtml String to clean
+ * @param string $stringtoclean String to clean
* @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed
* @param string $pagecodeto Encoding of input/output string
* @return string String cleaned
*
- * @see dol_escape_htmltag
+ * @see dol_escape_htmltag strip_tags
*/
-function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
+function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8')
{
+ // TODO Try to replace with strip_tags($stringtoclean)
$pattern = "/<[^<>]+>/";
- $StringHtml = preg_replace('/
]*>/', "\n", $StringHtml);
- $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto);
+ $stringtoclean = preg_replace('/
]*>/', "\n", $stringtoclean);
+ $temp = dol_html_entity_decode($stringtoclean,ENT_COMPAT,$pagecodeto);
// Exemple of $temp: 0000-021
$temp = preg_replace($pattern,"",$temp); // pass 1
@@ -4852,8 +4857,8 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
{
$temp = str_replace(" "," ",$temp);
}
- $CleanString = trim($temp);
- return $CleanString;
+
+ return trim($temp);
}