I have a PHP script as below:
10. $json_sanitized = ds($json);
11. echo json_encode ( $json_sanitized );
The ds()
function has few rules to sanitize the $json
data.
function ds($text, $double = true, $charset = null) {
if (is_array($text)) {
// Some code
} elseif (is_object($text)) {
// Some code
} elseif (is_bool($text)) {
// Some code
}
$defaultCharset = 'UTF-8';
if (is_string($double)) {
$charset = $double;
}
return htmlspecialchars($text, ENT_QUOTES, ($charset) ? $charset : $defaultCharset, $double);
}
But the HP Fortify Scanner still says, Line #11, sends unvalidated data to a web browser, which can result in the browser executing malicious code.
Can anyone help on this?