diff --git a/htdocs/includes/modules/export/export_csv.modules.php b/htdocs/includes/modules/export/export_csv.modules.php
index 8f87e6fb5af..8f081fb213f 100644
--- a/htdocs/includes/modules/export/export_csv.modules.php
+++ b/htdocs/includes/modules/export/export_csv.modules.php
@@ -206,7 +206,7 @@ class ExportCsv extends ModeleExports
$addquote=0;
// Rule Dolibarr: No HTML
- $newvalue=clean_html($newvalue);
+ $newvalue=dol_string_nohtmltag($newvalue);
// Rule 1 CSV: No CR, LF in cells
$newvalue=ereg_replace("\r",'',$newvalue);
diff --git a/htdocs/includes/modules/export/export_excel.modules.php b/htdocs/includes/modules/export/export_excel.modules.php
index c40ab061ee7..32251f3fa50 100644
--- a/htdocs/includes/modules/export/export_excel.modules.php
+++ b/htdocs/includes/modules/export/export_excel.modules.php
@@ -192,8 +192,9 @@ class ExportExcel extends ModeleExports
{
$alias=$array_alias[$code];
$newvalue=$objp->$alias;
- // Nettoyage newvalue
- $newvalue=clean_html($newvalue);
+
+ $newvalue=$this->excel_clean($newvalue);
+
// Traduction newvalue
if (eregi('^\((.*)\)$',$newvalue,$reg))
{
@@ -241,6 +242,19 @@ class ExportExcel extends ModeleExports
return 0;
}
+
+ /**
+ * Clean a cell to respect rules of Excel file cells
+ * @param newvalue String to clean
+ * @return string Value cleaned
+ */
+ function excel_clean($newvalue)
+ {
+ // Rule Dolibarr: No HTML
+ $newvalue=dol_string_nohtmltag($newvalue);
+
+ return $newvalue;
+ }
}
?>
diff --git a/htdocs/includes/modules/export/export_tsv.modules.php b/htdocs/includes/modules/export/export_tsv.modules.php
index f3d0c9e036b..5c4ebcc72cf 100644
--- a/htdocs/includes/modules/export/export_tsv.modules.php
+++ b/htdocs/includes/modules/export/export_tsv.modules.php
@@ -204,7 +204,7 @@ class ExportTsv extends ModeleExports
function tsv_clean($newvalue)
{
// Rule Dolibarr: No HTML
- $newvalue=clean_html($newvalue);
+ $newvalue=dol_string_nohtmltag($newvalue);
// Rule 1 TSV: No CR, LF in cells
$newvalue=ereg_replace("\r",'',$newvalue);
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 4abdd9e8a64..f84699911e6 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -2626,12 +2626,12 @@ function clean_url($url,$http=1)
/**
- * \brief Clean a string from all html tags
+ * \brief Clean a string from all HTML tags and entities
* \param StringHtml String to clean
* \param removelinefeed Replace also all lines feeds by a space
* \return string String cleaned
*/
-function clean_html($StringHtml,$removelinefeed=1)
+function dol_string_nohtmltag($StringHtml,$removelinefeed=1)
{
$pattern = "<[^>]+>";
$temp = dol_entity_decode($StringHtml);
@@ -2748,13 +2748,15 @@ function dol_htmlcleanlastbr($stringtodecode)
}
/**
- * \brief This function is called to decode a HTML string (it decodes entities tags)
+ * \brief This function is called to decode a string with HTML entities (it decodes entities tags)
* \param string stringhtml
* \return string decodestring
*/
function dol_entity_decode($stringhtml,$pagecodeto='UTF-8')
{
- $ret=html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto);
+ //print 'x'.$stringhtml;
+ //$ret=html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto);
+ $ret=html_entity_decode($stringhtml,ENT_COMPAT);
return $ret;
}
diff --git a/htdocs/lib/xcal.lib.php b/htdocs/lib/xcal.lib.php
index b8c3115c3d5..994b8a33c3c 100644
--- a/htdocs/lib/xcal.lib.php
+++ b/htdocs/lib/xcal.lib.php
@@ -87,7 +87,7 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
$url = $event['url'];
$transparency = $event['transparency']; // OPAQUE or TRANSPARENT
$description=eregi_replace('
',"\n",$event['desc']);
- $description=clean_html($description,0); // Remove html tags
+ $description=dol_string_nohtmltag($description,0); // Remove html tags
// Uncomment for tests
//$summary="Resume";
@@ -296,7 +296,7 @@ function build_rssfile($format='rss',$title,$desc,$events_array,$outputfile,$fil
$author = $event['author'];
$category = $event['category'];
$description=eregi_replace('
',"\n",$event['desc']);
- $description=clean_html($description,0); // Remove html tags
+ $description=dol_string_nohtmltag($description,0); // Remove html tags
fwrite ($fichier, "- \n");
fwrite ($fichier, ""."\n");