diff --git a/php/get.php b/php/get.php index 55b6dc7f..d6385794 100644 --- a/php/get.php +++ b/php/get.php @@ -12,4 +12,18 @@ for($i = sizeof($list)-1; $i >= 0; $i--) { unset($list[$i]); } -echo json_encode(array_values($list)); \ No newline at end of file +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; +} + +// Protect against XSS attacks +$list = filterArray($list); +echo json_encode(array_values($list));