Debug v19

This commit is contained in:
Laurent Destailleur
2023-10-29 16:44:41 +01:00
parent d285f03120
commit 582a6f7f45
3 changed files with 71 additions and 52 deletions

View File

@@ -1598,18 +1598,26 @@ function dol_escape_json($stringtoescape)
}
/**
* Returns text escaped for inclusion into a php string, build with double quotes "
* Returns text escaped for inclusion into a php string, build with double quotes " or '
*
* @param string $stringtoescape String to escape
* @param string $stringforquotes 2=String for doublequotes, 1=String for simple quotes
* @return string Escaped string for json content.
*/
function dol_escape_php($stringtoescape)
function dol_escape_php($stringtoescape, $stringforquotes = 2)
{
if (is_null($stringtoescape)) {
return '';
}
return str_replace('"', "'", $stringtoescape);
if ($stringforquotes == 2) {
return str_replace('"', "'", $stringtoescape);
}
if ($stringforquotes == 1) {
return str_replace("'", "\'", str_replace('"', "'", $stringtoescape));
}
return 'Bad parameter for stringforquotes in dol_escape_php';
}
/**