diff options
author | David Woods <d.woods92@gmail.com> | 2015-03-17 07:36:54 +0100 |
---|---|---|
committer | David Woods <d.woods92@gmail.com> | 2015-03-17 07:36:54 +0100 |
commit | dc1ae6bd92bc0f2c3ee5ce812ec60e580c72501d (patch) | |
tree | 0f570870e66a8b54aecfb81d9150a1fc9097d5ee /system | |
parent | f3ac71ea74351dc075d95867612da46834eccdf3 (diff) |
Fixed bugs in form_validation for methods matches, differs, and valid_base64.
Implemented tests for valid and invalid inputs for all basic rules available for form_validation.
The invalid input data currently doesn't pass all tests.
Signed-off-by: David Woods <d.woods92@gmail.com>
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Form_validation.php | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 05de59628..32ea4b1b4 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1091,14 +1091,12 @@ class CI_Form_validation { * Match one field to another * * @param string $str string to compare against - * @param string $field + * @param string $param The string desired * @return bool */ - public function matches($str, $field) + public function matches($str, $param) { - return isset($this->_field_data[$field], $this->_field_data[$field]['postdata']) - ? ($str === $this->_field_data[$field]['postdata']) - : FALSE; + return ($str === $param); } // -------------------------------------------------------------------- @@ -1107,12 +1105,12 @@ class CI_Form_validation { * Differs from another field * * @param string - * @param string field + * @param string param is the value provided in the form * @return bool */ - public function differs($str, $field) + public function differs($str, $param) { - return ! (isset($this->_field_data[$field]) && $this->_field_data[$field]['postdata'] === $str); + return ($str !== $param); } // -------------------------------------------------------------------- @@ -1493,7 +1491,7 @@ class CI_Form_validation { */ public function valid_base64($str) { - return (base64_encode(base64_decode($str)) === $str); + return (base64_decode($str, true) !== false); } // -------------------------------------------------------------------- |