diff --git a/php/get.php b/php/get.php index a09ae2f3..12f0a321 100644 --- a/php/get.php +++ b/php/get.php @@ -16,4 +16,18 @@ for($i = sizeof($list)-1; $i >= 0; $i--) { unset($list[$i]); } +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));