diff options
-rw-r--r-- | system/core/Log.php | 4 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_redis.php | 15 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 7 | ||||
-rw-r--r-- | tests/codeigniter/core/Log_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Form_validation_test.php | 3 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 4 |
6 files changed, 20 insertions, 15 deletions
diff --git a/system/core/Log.php b/system/core/Log.php index 4338aa939..f37726e02 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -247,11 +247,11 @@ class CI_Log { * @param string $level The error level * @param string $date Formatted date string * @param string $message The log message - * @return string Formatted log line with a new line character '\n' at the end + * @return string Formatted log line with a new line character at the end */ protected function _format_line($level, $date, $message) { - return $level.' - '.$date.' --> '.$message."\n"; + return $level.' - '.$date.' --> '.$message.PHP_EOL; } // -------------------------------------------------------------------- diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 9cb5bb095..e10a5b344 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -135,10 +135,6 @@ class CI_Cache_redis extends CI_Driver { log_message('error', 'Cache: Redis connection refused ('.$e->getMessage().')'); } - - // Initialize the index of serialized values. - $serialized = $this->_redis->sMembers('_ci_redis_serialized'); - empty($serialized) OR $this->_serialized = array_flip($serialized); } // ------------------------------------------------------------------------ @@ -153,7 +149,7 @@ class CI_Cache_redis extends CI_Driver { $value = $this->_redis->get($key); - if ($value !== FALSE && isset($this->_serialized[$key])) + if ($value !== FALSE && $this->_redis->sIsMember('_ci_redis_serialized', $key)) { return unserialize($value); } @@ -184,9 +180,8 @@ class CI_Cache_redis extends CI_Driver isset($this->_serialized[$id]) OR $this->_serialized[$id] = TRUE; $data = serialize($data); } - elseif (isset($this->_serialized[$id])) + else { - $this->_serialized[$id] = NULL; $this->_redis->sRemove('_ci_redis_serialized', $id); } @@ -208,11 +203,7 @@ class CI_Cache_redis extends CI_Driver return FALSE; } - if (isset($this->_serialized[$key])) - { - $this->_serialized[$key] = NULL; - $this->_redis->sRemove('_ci_redis_serialized', $key); - } + $this->_redis->sRemove('_ci_redis_serialized', $key); return TRUE; } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 1bd55499a..fdf202010 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1208,6 +1208,13 @@ class CI_Form_validation { $str = $matches[2]; } + // 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)) + { + return FALSE; + } + // PHP 7 accepts IPv6 addresses within square brackets as hostnames, // but it appears that the PR that came in with https://bugs.php.net/bug.php?id=68039 // was never merged into a PHP 5 branch ... https://3v4l.org/8PsSN diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php index 103af342b..927984385 100644 --- a/tests/codeigniter/core/Log_test.php +++ b/tests/codeigniter/core/Log_test.php @@ -57,7 +57,7 @@ class Log_test extends CI_TestCase { $format_line->setAccessible(TRUE); $this->assertEquals( $format_line->invoke($instance, 'LEVEL', 'Timestamp', 'Message'), - "LEVEL - Timestamp --> Message\n" + "LEVEL - Timestamp --> Message".PHP_EOL ); } } diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 3280f5bd8..6872b3abd 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -262,6 +262,9 @@ class Form_validation_test extends CI_TestCase { // URI scheme case-sensitivity: https://github.com/bcit-ci/CodeIgniter/pull/4758 $this->assertTrue($this->form_validation->valid_url('HtTp://127.0.0.1/')); + // https://github.com/bcit-ci/CodeIgniter/issues/5755 + $this->assertFalse($this->form_validation->valid_url('1')); + $this->assertFalse($this->form_validation->valid_url('htt://www.codeIgniter.com')); $this->assertFalse($this->form_validation->valid_url('')); $this->assertFalse($this->form_validation->valid_url('code igniter')); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0a05d6906..aeea47578 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -7,6 +7,9 @@ Version 3.1.11 Release Date: Not Released +- General Changes + + - Changed ``CI_Log`` to append ``PHP_EOL`` instead of ``\n`` at the end of log messages. Bug fixes for 3.1.11 ==================== @@ -17,6 +20,7 @@ Bug fixes for 3.1.11 - Fixed a bug (#5708) - :doc:`Session Library <libraries/session>` 'redis' driver too often failed with locking-related errors that could've been avoided. - Fixed a bug (#5703) - :doc:`Session Library <libraries/session>` triggered an ``E_WARNING`` message about changing ``session.save_path`` during an active session when it fails to obtain a lock. - Fixed a bug where :doc:`Session Library <libraries/session>` 'database' driver didn't trigger a failure if it can't obtain a lock. +- Fixed a bug (#5755) - :doc:`Form Validation Library <libraries/form_validation>` rule **valid_url** accepted digit-only domains due to a PHP bug. Version 3.1.10 ============== |