Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ctype int string cast #6289

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/database/DB_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ public function escape_identifiers($item, $split = TRUE)
return $item;
}
// Avoid breaking functions and literal values inside queries
elseif (ctype_digit($item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
elseif (ctype_digit((string) $item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
{
return $item;
}
Expand Down
2 changes: 1 addition & 1 deletion system/database/DB_query_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2782,7 +2782,7 @@ protected function _is_literal($str)
{
$str = trim($str);

if (empty($str) OR ctype_digit($str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
if (empty($str) OR ctype_digit((string) $str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
{
return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions system/database/drivers/oci8/oci8_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function __construct($params)
return;
}
elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE
&& (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== ''))
&& (( ! empty($this->port) && ctype_digit((string) $this->port)) OR $this->database !== ''))
{
/* If the hostname field isn't empty, doesn't contain
* ':' and/or '/' and if port and/or database aren't
Expand All @@ -187,7 +187,7 @@ public function __construct($params)
* that the database field is a service name.
*/
$this->dsn = $this->hostname
.(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '')
.(( ! empty($this->port) && ctype_digit((string) $this->port)) ? ':'.$this->port : '')
.($this->database !== '' ? '/'.ltrim($this->database, '/') : '');

if (preg_match($valid_dsns['ec'], $this->dsn))
Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/postgre/postgre_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function _build_dsn()

$this->hostname === '' OR $this->dsn = 'host='.$this->hostname.' ';

if ( ! empty($this->port) && ctype_digit($this->port))
if ( ! empty($this->port) && ctype_digit((string) $this->port))
{
$this->dsn .= 'port='.$this->port.' ';
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Form_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ public function valid_url($str)

// Apparently, FILTER_VALIDATE_URL doesn't reject digit-only names for some reason ...
// See https://github.com/bcit-ci/CodeIgniter/issues/5755
if (ctype_digit($str))
if (ctype_digit((string) $str))
{
return FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Image_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public function initialize($props = array())
// Set the quality
$this->quality = trim(str_replace('%', '', $this->quality));

if ($this->quality === '' OR $this->quality === 0 OR ! ctype_digit($this->quality))
if ($this->quality === '' OR $this->quality === 0 OR ! ctype_digit((string) $this->quality))
{
$this->quality = 90;
}
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ protected function _configure_sid_length()
if (PHP_VERSION_ID < 70100)
{
$hash_function = ini_get('session.hash_function');
if (ctype_digit($hash_function))
if (ctype_digit((string) $hash_function))
{
if ($hash_function !== '1')
{
Expand Down
Loading