Fix for XSS bug

I actually tested this one! it works.
My apologies for the previous, non-working commits-- I had to refresh my knowledge of PHP.
This commit is contained in:
Rory M
2016-04-22 14:27:21 +01:00
parent b91b7cacb0
commit 26d54cfa9b
+13 -1
View File
@@ -47,6 +47,18 @@
$data = array_merge($data, getAllQueries());
}
foreach ($data as &$d) $d = htmlspecialchars($d);
function filterArray(&$a) {
$sanArray = array();
foreach ($a as $k=>$v) {
if (is_array($v)) {
$sanArray[htmlspecialchars($k)] = filterArray($v);
} else {
$sanArray[htmlspecialchars($k)] = htmlspecialchars($v);
}
}
return $sanArray;
}
$data = filterArray($data);
echo json_encode($data);
?>