Skip to content

Commit

Permalink
Cast variables to string for ctype_digit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Burchell committed Jul 15, 2024
1 parent 6a35c0f commit ac51489
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion system/database/DB_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,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 @@ -639,7 +639,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

0 comments on commit ac51489

Please sign in to comment.