From 475dfac090505832719cb6ff4ff13ab7ac655fbb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Apr 2015 00:07:04 +0300 Subject: Disallow empty FV rules ... for consistency Related: #3736 --- system/libraries/Form_validation.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'system/libraries/Form_validation.php') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 05de59628..522eba704 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -198,22 +198,20 @@ class CI_Form_validation { return $this; } - // No fields? Nothing to do... - if ( ! is_string($field) OR $field === '') + // No fields or no rules? Nothing to do... + if ( ! is_string($field) OR $field === '' OR empty($rules)) { return $this; } elseif ( ! is_array($rules)) { // BC: Convert pipe-separated rules string to an array - if (is_string($rules)) - { - $rules = explode('|', $rules); - } - else + if ( ! is_string($rules)) { return $this; } + + $rules = explode('|', $rules); } // If the field label wasn't passed we use the field name -- cgit v1.2.3-24-g4f1b From 5d8e2a6e4c50b772f4b789ea5d831f47c45dc851 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 14 Apr 2015 16:56:28 +0300 Subject: Fix #3771 --- system/libraries/Form_validation.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'system/libraries/Form_validation.php') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 522eba704..bb872c7cc 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -870,17 +870,11 @@ class CI_Form_validation { */ protected function _translate_fieldname($fieldname) { - // Do we need to translate the field name? - // We look for the prefix lang: to determine this - if (sscanf($fieldname, 'lang:%s', $line) === 1) + // Do we need to translate the field name? We look for the prefix 'lang:' to determine this + // If we find one, but there's no translation for the string - just return it + if (sscanf($fieldname, 'lang:%s', $line) === 1 && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE))) { - // Were we able to translate the field name? If not we use $line - if (FALSE === ($fieldname = $this->CI->lang->line('form_validation_'.$line)) - // DEPRECATED support for non-prefixed keys - && FALSE === ($fieldname = $this->CI->lang->line($line, FALSE))) - { - return $line; - } + return $line; } return $fieldname; -- cgit v1.2.3-24-g4f1b From b137d232ef895cc47da4e39dfcb7c9078ba6be2b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Apr 2015 11:44:38 +0300 Subject: Fix #3816 --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Form_validation.php') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bb872c7cc..7599602c0 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -461,7 +461,7 @@ class CI_Form_validation { { $this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']); } - elseif (isset($validation_array[$field]) && $validation_array[$field] !== '') + elseif (isset($validation_array[$field])) { $this->_field_data[$field]['postdata'] = $validation_array[$field]; } -- cgit v1.2.3-24-g4f1b