diff --git a/cake/libs/validation.php b/cake/libs/validation.php index fce432afa..e42bf4d02 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -124,6 +124,10 @@ class Validation extends Object { $this->_extract($check); } + if(empty($this->check)) { + return false; + } + $this->regex = '/[^\\dA-Z]/i'; if($this->_check() === true){ return false; diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 15a3ddcbc..0d98bb8b4 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -47,6 +47,7 @@ class ValidationTestCase extends UnitTestCase { $this->assertFalse($validation->alphaNumeric("\t")); $this->assertFalse($validation->alphaNumeric("\r")); $this->assertFalse($validation->alphaNumeric(' ')); + $this->assertFalse($validation->alphaNumeric('')); } function testAlphaNumericPassedAsArray(){ @@ -61,6 +62,7 @@ class ValidationTestCase extends UnitTestCase { $this->assertFalse($validation->alphaNumeric(array('check' => "\t"))); $this->assertFalse($validation->alphaNumeric(array('check' => "\r"))); $this->assertFalse($validation->alphaNumeric(array('check' => ' '))); + $this->assertFalse($validation->alphaNumeric(array('check' => ''))); } function testBetween(){