Skip to content

Commit

Permalink
Merge pull request #84 from roddux/xss-patch-devel
Browse files Browse the repository at this point in the history
Fix for XSS bug
  • Loading branch information
PromoFaux committed Apr 22, 2016
2 parents 861be94 + 26d54cf commit cb57c0c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion api.php
Expand Up @@ -47,6 +47,18 @@
$data = array_merge($data, getAllQueries());
}


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);
?>

0 comments on commit cb57c0c

Please sign in to comment.