2
0
forked from Wavyzz/dolibarr

Add dol_escape_json method

This commit is contained in:
Laurent Destailleur
2020-03-20 17:10:35 +01:00
parent aa1f601528
commit f904ff5240
2 changed files with 36 additions and 14 deletions

View File

@@ -984,6 +984,16 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
return strtr($stringtoescape, $substitjs);
}
/**
* Returns text escaped for inclusion into javascript code
*
* @param string $stringtoescape String to escape
* @return string Escaped string for json content.
*/
function dol_escape_json($stringtoescape)
{
return str_replace('"', '\"', $stringtoescape);
}
/**
* Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.