From 10776ccb00c5216a12b8cfae09434924cfa77f78 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 1 Dec 2014 13:56:16 +0200 Subject: Fix #3380 --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index c7326cd35..b011d5b5a 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2319,7 +2319,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Split multiple conditions $conditions = preg_split( - '/(\s*AND\s+|\s*OR\s+)/i', + '/(\s+AND\s+|\s+OR\s+)/i', $this->{$qb_key}[$i]['condition'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY -- cgit v1.2.3-24-g4f1b From 7d1554a3f40c3bc453aeae3b960ae7394c4174c9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 1 Dec 2014 14:09:51 +0200 Subject: Fix a regression from the previous commit --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index b011d5b5a..1a6cea441 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2319,7 +2319,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Split multiple conditions $conditions = preg_split( - '/(\s+AND\s+|\s+OR\s+)/i', + '/(\bAND\s+|\bOR\s+)/i', $this->{$qb_key}[$i]['condition'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY -- cgit v1.2.3-24-g4f1b From ab9217e316a79bc8fab2840c8f5bd2b9bc7a4dc0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 2 Dec 2014 00:15:42 +0200 Subject: Improve on the fix for #3380 --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 1a6cea441..621480635 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2319,7 +2319,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Split multiple conditions $conditions = preg_split( - '/(\bAND\s+|\bOR\s+)/i', + '/(?!<[\'"].*)(\s*AND\s+|\s*OR\s+)(?!.*[\'"])/i', $this->{$qb_key}[$i]['condition'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY -- cgit v1.2.3-24-g4f1b From 5078eb5062457c1eef2fab0c58fa27f249616b78 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 2 Dec 2014 01:11:54 +0200 Subject: Regressions ... #3380 #3194 ab9217e316a79bc8fab2840c8f5bd2b9bc7a4dc0 --- system/database/DB_driver.php | 5 +++-- system/database/DB_query_builder.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 0b4707370..7c3df42b8 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1461,7 +1461,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(<|>|!|=|\sIS\s|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1485,7 +1485,8 @@ abstract class CI_DB_driver { '\s*(?:<|>|!)?=\s*', // =, <=, >=, != '\s*<>?\s*', // <, <> '\s*>\s*', // > - '\s+IS(?:\sNOT)?(?:\sNULL)?', // IS[ NOT] NULL + '\s+IS NULL', // IS NULL + '\s+IS NOT NULL', // IS NOT NULL '\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql) '\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql) '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 621480635..1c0aed693 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -672,7 +672,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // value appears not to have been set, assign the test to IS NULL $k .= ' IS NULL'; } - elseif (preg_match('/\s*(!?=|<>)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE)) + elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE)) { $k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL'); } @@ -2319,7 +2319,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Split multiple conditions $conditions = preg_split( - '/(?!<[\'"].*)(\s*AND\s+|\s*OR\s+)(?!.*[\'"])/i', + '/(\s*AND\s+|\s*OR\s+)/i', $this->{$qb_key}[$i]['condition'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY -- cgit v1.2.3-24-g4f1b From 89432af4adb4011ad8aa5252838dc76a3a5acec7 Mon Sep 17 00:00:00 2001 From: Ahmad Anbar Date: Tue, 2 Dec 2014 10:04:46 +0200 Subject: Allow pulling multiple get/post ...etc at once --- system/core/Input.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 81555df9a..0dcb6f425 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -168,6 +168,18 @@ class CI_Input { return $output; } + // allow fetching multiple keys at once + if (is_array($index)) + { + $output = array(); + foreach($index as $var) + { + $output[$var] = $this->_fetch_from_array($array, $var, $xss_clean); + } + + return $output; + } + is_bool($xss_clean) OR $xss_clean = $this->_enable_xss; if (isset($array[$index])) -- cgit v1.2.3-24-g4f1b From ff89a4e7709933dda52698cd4abd389754ae8675 Mon Sep 17 00:00:00 2001 From: Ahmad Anbar Date: Tue, 2 Dec 2014 17:26:30 +0200 Subject: Added changelog entry updated documentation Fixed code style. --- system/core/Input.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 0dcb6f425..11b2e94e0 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -150,7 +150,7 @@ class CI_Input { * Internal method used to retrieve values from global arrays. * * @param array &$array $_GET, $_POST, $_COOKIE, $_SERVER, etc. - * @param string $index Index for item to be fetched from $array + * @param mixed $index Index for item to be fetched from $array * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ @@ -172,7 +172,7 @@ class CI_Input { if (is_array($index)) { $output = array(); - foreach($index as $var) + foreach ($index as $var) { $output[$var] = $this->_fetch_from_array($array, $var, $xss_clean); } @@ -222,7 +222,7 @@ class CI_Input { /** * Fetch an item from the GET array * - * @param string $index Index for item to be fetched from $_GET + * @param mixed $index Index for item to be fetched from $_GET * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ @@ -236,7 +236,7 @@ class CI_Input { /** * Fetch an item from the POST array * - * @param string $index Index for item to be fetched from $_POST + * @param mixed $index Index for item to be fetched from $_POST * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ @@ -282,7 +282,7 @@ class CI_Input { /** * Fetch an item from the COOKIE array * - * @param string $index Index for item to be fetched from $_COOKIE + * @param mixed $index Index for item to be fetched from $_COOKIE * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ @@ -296,7 +296,7 @@ class CI_Input { /** * Fetch an item from the SERVER array * - * @param string $index Index for item to be fetched from $_SERVER + * @param mixed $index Index for item to be fetched from $_SERVER * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ -- cgit v1.2.3-24-g4f1b From ef29f83f786aa968be3d9b7b55ccdc45f33c475d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 2 Dec 2014 18:03:47 +0200 Subject: Some optimizations & polishing following PR #3381 --- system/core/Input.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 11b2e94e0..d1353e9dc 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -156,32 +156,23 @@ class CI_Input { */ protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL) { - // If $index is NULL, it means that the whole $array is requested - if ($index === NULL) - { - $output = array(); - foreach (array_keys($array) as $key) - { - $output[$key] = $this->_fetch_from_array($array, $key, $xss_clean); - } + is_bool($xss_clean) OR $xss_clean = $this->_enable_xss; - return $output; - } + // If $index is NULL, it means that the whole $array is requested + isset($index) OR $index = array_keys($array); // allow fetching multiple keys at once if (is_array($index)) { $output = array(); - foreach ($index as $var) + foreach (array_keys($array) as $key) { - $output[$var] = $this->_fetch_from_array($array, $var, $xss_clean); + $output[$key] = $this->_fetch_from_array($array, $key, $xss_clean); } return $output; } - is_bool($xss_clean) OR $xss_clean = $this->_enable_xss; - if (isset($array[$index])) { $value = $array[$index]; -- cgit v1.2.3-24-g4f1b From 6b3bf4c026cb8cb85ce53a985c64b22006695ce6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 2 Dec 2014 18:04:41 +0200 Subject: Fix an error from the previous commit --- system/core/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index d1353e9dc..0c6025d1e 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -165,7 +165,7 @@ class CI_Input { if (is_array($index)) { $output = array(); - foreach (array_keys($array) as $key) + foreach ($index as $key) { $output[$key] = $this->_fetch_from_array($array, $key, $xss_clean); } -- cgit v1.2.3-24-g4f1b