diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 2ca44a14469..9cff7342f14 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -194,9 +194,9 @@ function dol_escape_js($stringtoescape)
function dol_escape_htmltag($stringtoescape)
{
// escape quotes and backslashes, newlines, etc.
- $tmp=@html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8');
+ $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8');
$tmp=strtr($tmp, array('"'=>'',"\r"=>'\\r',"\n"=>'\\n',""=>'',''=>''));
- return @htmlentities($tmp,ENT_COMPAT,'UTF-8');
+ return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8');
}
@@ -2888,17 +2888,16 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8')
{
if (dol_textishtml($stringtoencode))
{
- //$trans = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT); var_dump($trans);
$newstring=preg_replace('/
/i','
',$stringtoencode); // Replace "
" by "
". It's same and avoid pb with FPDF.
$newstring=preg_replace('/
$/i','',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF.
$newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__'));
- $newstring=@htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding
+ $newstring=dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding
$newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"'));
// If already HTML, CR should be
so we don't change \n
}
else {
// We use @ to avoid warning on PHP4 that does not support entity encoding from UTF8;
- $newstring=dol_nl2br(@htmlentities($stringtoencode,ENT_COMPAT,$pagecodefrom),$nl2brmode);
+ $newstring=dol_nl2br(dol_htmlentities($stringtoencode,ENT_COMPAT,$pagecodefrom),$nl2brmode);
}
// Other substitutions that htmlentities does not do
$newstring=str_replace(chr(128),'€',$newstring); // 128 = 0x80. Not in html entity table.
@@ -2911,8 +2910,7 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8')
*/
function dol_htmlentitiesbr_decode($stringtodecode,$pagecodeto='UTF-8')
{
- // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
- $ret=@html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto);
+ $ret=dol_html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto);
$ret=preg_replace('/'."\r\n".'
/i',"
",$ret);
$ret=preg_replace('/
'."\r\n".'/i',"\r\n",$ret);
$ret=preg_replace('/
'."\n".'/i',"\n",$ret);
@@ -2937,11 +2935,37 @@ function dol_htmlcleanlastbr($stringtodecode)
*/
function dol_entity_decode($stringhtml,$pagecodeto='UTF-8')
{
- // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
- $ret=@html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto);
+ $ret=dol_html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto);
return $ret;
}
+/**
+ * Replace html_entity_decode functions to manage errors
+ * @param unknown_type $a
+ * @param unknown_type $b
+ * @param unknown_type $c
+ */
+function dol_html_entity_decode($a,$b,$c)
+{
+ // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
+ $ret=@html_entity_decode($a,$b,$c);
+ return $ret;
+}
+
+/**
+ * Replace htmlentities functions to manage errors
+ * @param unknown_type $a
+ * @param unknown_type $b
+ * @param unknown_type $c
+ */
+function dol_htmlentities($a,$b,$c)
+{
+ // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
+ $ret=@htmlentities($a,$b,$c);
+ return $ret;
+}
+
+
/**
* \brief Check if a string is a correct iso string
* If not, it will we considered not HTML encoded even if it is by FPDF.
diff --git a/htdocs/lib/ldap.lib.php b/htdocs/lib/ldap.lib.php
index 8736e03cde8..514ecdd3518 100644
--- a/htdocs/lib/ldap.lib.php
+++ b/htdocs/lib/ldap.lib.php
@@ -107,7 +107,7 @@ function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass)
/**
- * Show an LDAP array in an HTML to records.
+ * Show a LDAP array into an HTML output array.
*
* @param $result Array to show. This array is already encoded into charset_output
* @param $level
@@ -151,7 +151,7 @@ function show_ldap_content($result,$level,$count,$var,$hide=0,$subcount=0)
else if ($subcount)
{
$subcount--;
- $newstring=@htmlentities($val,ENT_COMPAT,'UTF-8'); // Make entity encoding
+ $newstring=dol_htmlentitiesbr($val);
if ($hide) print preg_replace('/./i','*',$newstring);
else print $newstring;
print '
';