# HG changeset patch # User Matti Hamalainen # Date 1297720509 -7200 # Node ID b4b86915ae2c12fb2543cff89120c5ebc3031926 # Parent f025d36926a1ba55a7b3a04d39b6cc1b46ad5d21 Better input validation for $_GET arguments, thanks to Hjalmarr for pointing out the error. diff -r f025d36926a1 -r b4b86915ae2c index.php --- a/index.php Tue Jan 25 19:51:39 2011 +0200 +++ b/index.php Mon Feb 14 23:55:09 2011 +0200 @@ -36,12 +36,14 @@ function checkClassID(&$id) { global $luokkaDefault; - if (!preg_match("#^[A-Z]{3}\d\S+|ccr#", $id)) { + if (preg_match("#^([A-Z]{3}\d[A-Za-z0-9_]{1,6}|ccr|Ryh_[A-Z]{3}\d[A-Za-z0-9_]{1,6})$#", $id, $m)) { + $id = $m[1]; + return TRUE; + } else { errorMsg("Virhe! Luokan täytyy olla muotoa XXXnXXX, käytetään vakioarvoa ".$luokkaDefault."."); $id = $luokkaDefault; return FALSE; - } else - return TRUE; + } } // Check for mini-info mode