From b90011aeb19857d72738f1ff6254b882c2e3746d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Oct 2014 01:01:30 +0200 Subject: [PATCH] Add function dolEscapeXML --- htdocs/core/lib/functions.lib.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index edf0b1b9dcd..7b79adc86c4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -453,6 +453,18 @@ function dol_string_nospecial($str,$newstr='_',$badchars='') return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); } + +/** + * Encode string for xml usage + * + * @param string $string String to encode + * @return string String encoded + */ +function dolEscapeXML($string) +{ + return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>')); +} + /** * Returns text escaped for inclusion into javascript code * @@ -3715,6 +3727,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) } } + /** * This function is called to encode a string into a HTML string but differs from htmlentities because * all entities but &,<,> are converted. This permits to encode special chars to entities with no double