From 4131d42c793c3db50b6184e5084332d5415c91cb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 25 Sep 2017 19:47:49 +0300 Subject: [PATCH 01/26] [ci skip] Mark the start of 3.1.7-dev --- system/core/CodeIgniter.php | 2 +- user_guide_src/source/changelog.rst | 6 ++++++ user_guide_src/source/conf.py | 4 ++-- user_guide_src/source/installation/downloads.rst | 3 ++- user_guide_src/source/installation/upgrade_317.rst | 14 ++++++++++++++ user_guide_src/source/installation/upgrading.rst | 1 + 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 user_guide_src/source/installation/upgrade_317.rst diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 0d03293f6..a4c7d5553 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -55,7 +55,7 @@ * @var string * */ - const CI_VERSION = '3.1.6'; + const CI_VERSION = '3.1.7-dev'; /* * ------------------------------------------------------ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e5387cc5a..b99a709ad 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -2,6 +2,12 @@ Change Log ########## +Version 3.1.7 +============= + +Release Date: Not Released + + Version 3.1.6 ============= diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 7929f8ae7..e2b1c2972 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = '3.1.6' +version = '3.1.7-dev' # The full version, including alpha/beta/rc tags. -release = '3.1.6' +release = '3.1.7-dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst index 76335bb67..bb7534d91 100644 --- a/user_guide_src/source/installation/downloads.rst +++ b/user_guide_src/source/installation/downloads.rst @@ -2,7 +2,8 @@ Downloading CodeIgniter ####################### -- `CodeIgniter v3.1.6 (Current version) `_ +- `CodeIgniter v3.1.7-dev (Current version) `_ +- `CodeIgniter v3.1.6 `_ - `CodeIgniter v3.1.5 `_ - `CodeIgniter v3.1.4 `_ - `CodeIgniter v3.1.3 `_ diff --git a/user_guide_src/source/installation/upgrade_317.rst b/user_guide_src/source/installation/upgrade_317.rst new file mode 100644 index 000000000..93c37b687 --- /dev/null +++ b/user_guide_src/source/installation/upgrade_317.rst @@ -0,0 +1,14 @@ +############################# +Upgrading from 3.1.6 to 3.1.7 +############################# + +Before performing an update you should take your site offline by +replacing the index.php file with a static one. + +Step 1: Update your CodeIgniter files +===================================== + +Replace all files and directories in your *system/* directory. + +.. note:: If you have any custom developed files in these directories, + please make copies of them first. diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst index 991d5cf4c..1cc249869 100644 --- a/user_guide_src/source/installation/upgrading.rst +++ b/user_guide_src/source/installation/upgrading.rst @@ -8,6 +8,7 @@ upgrading from. .. toctree:: :titlesonly: + Upgrading from 3.1.6 to 3.1.7 Upgrading from 3.1.5 to 3.1.6 Upgrading from 3.1.4 to 3.1.5 Upgrading from 3.1.3 to 3.1.4 From a9194650e6ae387be29aacfdf4b1b27a5c60ca34 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 27 Sep 2017 18:57:46 +0300 Subject: [PATCH 02/26] Fix #5276 --- system/database/drivers/mysqli/mysqli_result.php | 14 +++----------- system/database/drivers/mysqli/mysqli_utility.php | 6 +----- user_guide_src/source/changelog.rst | 5 +++++ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 0b3d9c2b4..bd465c405 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -130,10 +130,10 @@ public function field_data() * mysqli_result::fetch_fields() * * @used-by CI_DB_mysqli_result::field_data() - * @param int $flags + * @param int $type * @return string */ - private static function _get_field_type($flags) + private static function _get_field_type($type) { static $map; isset($map) OR $map = array( @@ -164,15 +164,7 @@ private static function _get_field_type($flags) MYSQLI_TYPE_GEOMETRY => 'geometry' ); - foreach ($map as $flag => $name) - { - if ($flags & $flag) - { - return $name; - } - } - - return $flags; + return isset($map[$type]) ? $map[$type] : $type; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 1699b611f..82cf5cebf 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -155,11 +155,7 @@ protected function _backup($params = array()) while ($field = $query->result_id->fetch_field()) { // Most versions of MySQL store timestamp as a string - $is_int[$i] = ($field->type & MYSQLI_TYPE_TINY) - OR ($field->type & MYSQLI_TYPE_SHORT) - OR ($field->type & MYSQLI_TYPE_INT24) - OR ($field->type & MYSQLI_TYPE_LONG) - OR ($field->type & MYSQLI_TYPE_LONGLONG); + $is_int[$i] = in_array($field->type, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_INT24, MYSQLI_TYPE_LONG), TRUE); // Create a string of field names $field_str .= $this->db->escape_identifiers($field->name).', '; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index b99a709ad..2dd77e389 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -7,6 +7,11 @@ Version 3.1.7 Release Date: Not Released +Bug fixes for 3.1.7 +------------------- + +- Fixed a regression (#5276) - :doc:`Database Utilities ` method ``backup()`` generated incorrect ``INSERT`` statements with the 'mysqli' driver. +- Fixed a regression where :doc:`Database Results ` method ``field_data()`` returned incorrect type names. Version 3.1.6 ============= From d13babc46bf0e1de0f82cfdef859b949501f095b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 29 Sep 2017 12:00:24 +0300 Subject: [PATCH 03/26] Merge pull request #5278 from Uekawa/auto_link Fix auto_link trailing slash --- system/helpers/url_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 system/helpers/url_helper.php diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php old mode 100644 new mode 100755 index 84023affd..f6fb7d9eb --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -393,7 +393,7 @@ function safe_mailto($email, $title = '', $attributes = '') function auto_link($str, $type = 'both', $popup = FALSE) { // Find and replace any URLs. - if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w/?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { // Set our target HTML if using popup links. $target = ($popup) ? ' target="_blank"' : ''; From 00b050a5b4bb8a06e792cf297c4bcd3b9ede6d7e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 29 Sep 2017 12:02:06 +0300 Subject: [PATCH 04/26] [ci skip] Revert file permission change from PR #5278 --- system/helpers/url_helper.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 system/helpers/url_helper.php diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php old mode 100755 new mode 100644 From 6b08edf5d6ab24310460147a1c9785b80eca6304 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 29 Sep 2017 12:04:38 +0300 Subject: [PATCH 05/26] Add testcase and changelog entry for #5278 --- tests/codeigniter/helpers/url_helper_test.php | 5 +++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index 24823a634..5fbc364bf 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -53,7 +53,8 @@ public function test_auto_link_url() '
www.google.com' => '
www.google.com', 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at www.codeigniter.com. Period test.', 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at www.codeigniter.com, comma test', - 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' + 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: ://codeigniter.com must not break this one: http://codeigniter.com', + 'Trailing slash: https://codeigniter.com/ fubar' => 'Trailing slash: https://codeigniter.com/ fubar' ); foreach ($strings as $in => $out) @@ -76,4 +77,4 @@ public function test_pull_675() } } -} \ No newline at end of file +} diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2dd77e389..1c71b09ef 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -12,6 +12,7 @@ Bug fixes for 3.1.7 - Fixed a regression (#5276) - :doc:`Database Utilities ` method ``backup()`` generated incorrect ``INSERT`` statements with the 'mysqli' driver. - Fixed a regression where :doc:`Database Results ` method ``field_data()`` returned incorrect type names. +- Fixed a bug (#5278) - :doc:`URL Helper ` function :php:func:`auto_link()` didn't detect trailing slashes in URLs. Version 3.1.6 ============= From c495515f115685fbcb4180f4305ec2406144ca83 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 2 Oct 2017 10:50:21 +0300 Subject: [PATCH 06/26] [ci skip] Merge pull request #5281 from pawelkg/develop Adding some letters translated to Y in foregin_chars.php --- application/config/foreign_chars.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/foreign_chars.php b/application/config/foreign_chars.php index ac406e3d4..995f48304 100644 --- a/application/config/foreign_chars.php +++ b/application/config/foreign_chars.php @@ -59,8 +59,8 @@ '/Þ|þ/' => 'th', '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U', '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u', - '/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y', - '/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y', + '/Ƴ|Ɏ|Ỵ|Ẏ|Ӳ|Ӯ|Ў|Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y', + '/ẙ|ʏ|ƴ|ɏ|ỵ|ẏ|ӳ|ӯ|ў|ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y', '/В/' => 'V', '/в/' => 'v', '/Ŵ/' => 'W', From cf3924ec3f19fb6a3f4782cfe55e0c6314bcf94d Mon Sep 17 00:00:00 2001 From: pgee70 Date: Tue, 3 Oct 2017 10:09:04 +1100 Subject: [PATCH 07/26] Update DB_query_builder.php recent changes broke query ordering giving a warning in line 1238 = '$this->qb_cache_orderby = array_merge($this->qb_cache_orderby, $qb_orderby);' this was because on subsequent re-queries, the qb_cache_orderby was set to NULL not Array() as it is should be (and is instantiated originally . --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 81603bf31..72bd4e721 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1405,7 +1405,7 @@ public function count_all_results($table = '', $reset = TRUE) // for selecting COUNT(*) ... $qb_orderby = $this->qb_orderby; $qb_cache_orderby = $this->qb_cache_orderby; - $this->qb_orderby = $this->qb_cache_orderby = NULL; + $this->qb_orderby = $this->qb_cache_orderby = array(); $result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset) ? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results") From 9bba3aeca2b45728009e573e4d45a6ef760d5c33 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Oct 2017 14:21:36 +0300 Subject: [PATCH 08/26] [ci skip] Add changelog entry for #5282 --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1c71b09ef..c762df744 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -13,6 +13,7 @@ Bug fixes for 3.1.7 - Fixed a regression (#5276) - :doc:`Database Utilities ` method ``backup()`` generated incorrect ``INSERT`` statements with the 'mysqli' driver. - Fixed a regression where :doc:`Database Results ` method ``field_data()`` returned incorrect type names. - Fixed a bug (#5278) - :doc:`URL Helper ` function :php:func:`auto_link()` didn't detect trailing slashes in URLs. +- Fixed a regression (#5282) - :doc:`Query Builder ` method ``count_all_results()`` breaks ``ORDER BY`` clauses for subsequent queries. Version 3.1.6 ============= From 4c679b5e7c2363c2c815e310e31e0f982dba3863 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 4 Oct 2017 12:12:26 +0300 Subject: [PATCH 09/26] [ci skip] Fix a typo in pagination docs --- user_guide_src/source/libraries/pagination.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 99b5a80a2..fbc75ea56 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -128,7 +128,7 @@ the offset segment. **$config['suffix'] = '';** -A custom suffix added to the path. The sufix value will be right after +A custom suffix added to the path. The suffix value will be right after the offset segment. **$config['use_global_url_suffix'] = FALSE;** @@ -311,4 +311,4 @@ Class Reference :returns: HTML-formatted pagination :rtype: string - Returns a "pagination" bar, containing the generated links or an empty string if there's just a single page. \ No newline at end of file + Returns a "pagination" bar, containing the generated links or an empty string if there's just a single page. From 23aa166a7bef428cbbb06b3f6f7a3fa9f0e78524 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Oct 2017 10:57:57 +0300 Subject: [PATCH 10/26] [ci skip] Merge pull request #5292 from ajdunn2/develop Small spelling fix --- application/config/database.php | 2 +- user_guide_src/source/database/configuration.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/database.php b/application/config/database.php index bf9857fff..d22321e2a 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -47,7 +47,7 @@ | 'ssl_key' - Path to the private key file | 'ssl_cert' - Path to the public key certificate file | 'ssl_ca' - Path to the certificate authority file -| 'ssl_capath' - Path to a directory containing trusted CA certificats in PEM format +| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format | 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':') | 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only) | diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index e231a7d6a..a9bf7dcb6 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -186,7 +186,7 @@ Explanation of Values: - 'ssl_key' - Path to the private key file - 'ssl_cert' - Path to the public key certificate file - 'ssl_ca' - Path to the certificate authority file - - 'ssl_capath' - Path to a directory containing trusted CA certificats in PEM format + - 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format - 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':') - 'ssl_verify' - TRUE/FALSE; Whether to verify the server certificate or not ('mysqli' only) From 2e0247aac56f7076705211fb8845101697e62c05 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Oct 2017 11:00:03 +0300 Subject: [PATCH 11/26] [ci skip] Merge pull request #5295 from mamat-rahmat/fix-docs-code-block Fix broken .htaccess example code-block --- user_guide_src/source/general/urls.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst index e23554907..b8a1b9f5b 100644 --- a/user_guide_src/source/general/urls.rst +++ b/user_guide_src/source/general/urls.rst @@ -42,9 +42,9 @@ By default, the **index.php** file will be included in your URLs:: If your Apache server has *mod_rewrite* enabled, you can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected -except the specified items:: +except the specified items: -.. code-block:: console +.. code-block:: apache RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f From c54fd9116d49714390aa109cead0545c80ebb057 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 12 Oct 2017 12:56:09 +0300 Subject: [PATCH 12/26] Merge pull request #5289 from zploskey/cleanup_form_validation_tests Clean up form validation tests --- .../libraries/Form_validation_test.php | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index c9c404b43..fa9e86c97 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -305,9 +305,6 @@ public function test_rule_valid_base64() public function test_set_data() { - // Reset test environment - $_POST = array(); - $this->form_validation->reset_validation(); $data = array('field' => 'some_data'); $this->form_validation->set_data($data); $this->form_validation->set_rules('field', 'label', 'required'); @@ -326,9 +323,6 @@ public function test_set_data() public function test_set_message() { - // Reset test environment - $_POST = array(); - $this->form_validation->reset_validation(); $err_message = 'What a terrible error!'; $rules = array( array( @@ -356,7 +350,6 @@ public function test_set_message() public function test_set_error_delimiters() { - $this->form_validation->reset_validation(); $prefix = '
'; $suffix = '
'; $this->form_validation->set_error_delimiters($prefix, $suffix); @@ -367,11 +360,12 @@ public function test_set_error_delimiters() $this->assertTrue(strrpos($error_msg, $prefix) === 0); $this->assertTrue(strrpos($error_msg, $suffix, -strlen($suffix)) === (strlen($error_msg) - strlen($suffix))); + + $_POST = array(); } public function test_error_array() { - $this->form_validation->reset_validation(); $error_message = 'What a terrible error!'; $this->form_validation->set_message('required', $error_message); $this->form_validation->set_rules('foo', 'label', 'required'); @@ -379,11 +373,12 @@ public function test_error_array() $this->form_validation->run(); $error_array = $this->form_validation->error_array(); $this->assertEquals($error_message, $error_array['foo']); + + $_POST = array(); } public function test_error_string() { - $this->form_validation->reset_validation(); $error_message = 'What a terrible error!'; $prefix_default = ''; $suffix_default = ''; @@ -405,6 +400,8 @@ public function test_error_string() $_POST = array('foo' => 'bar'); $this->form_validation->run(); $this->assertEquals('', $this->form_validation->error_string()); + + $_POST = array(); } public function test_run() @@ -433,11 +430,12 @@ public function test_run() $form_validation = new CI_Form_validation($config); $this->assertFalse($form_validation->run('fail')); + + $_POST = array(); } public function test_has_rule() { - $this->form_validation->reset_validation(); $this->form_validation->set_rules('foo', 'label', 'required'); $this->assertTrue($this->form_validation->has_rule('foo')); @@ -446,7 +444,6 @@ public function test_has_rule() public function test_set_value() { - $this->form_validation->reset_validation(); $default = 'default'; $this->form_validation->set_rules('foo', 'label', 'required'); $this->form_validation->set_rules('bar[]', 'label', 'required'); @@ -458,13 +455,13 @@ public function test_set_value() $this->assertEquals('foo', $this->form_validation->set_value('foo', $default)); $this->assertEquals('bar1', $this->form_validation->set_value('bar[]', $default)); $this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default)); + + $_POST = array(); } public function test_set_select() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $_POST = array(); $this->form_validation->run(); $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); @@ -493,13 +490,13 @@ public function test_set_select() $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'bar', TRUE)); $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar')); $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar', TRUE)); + + $_POST = array(); } public function test_set_radio() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $_POST = array(); $this->form_validation->run(); $this->assertEquals('', $this->form_validation->set_radio('select', 'foo')); @@ -529,13 +526,13 @@ public function test_set_radio() $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'bar', TRUE)); $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar')); $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar', TRUE)); + + $_POST = array(); } public function test_set_checkbox() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $_POST = array(); $this->form_validation->run(); $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); @@ -564,6 +561,8 @@ public function test_set_checkbox() $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'bar', TRUE)); $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar')); $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar', TRUE)); + + $_POST = array(); } public function test_regex_match() @@ -612,13 +611,16 @@ public function run_rules($rules, $values) { $this->form_validation->reset_validation(); $_POST = array(); - $this->form_validation->set_rules($rules); + foreach ($values as $field => $value) { $_POST[$field] = $value; } - return $this->form_validation->run(); + $valid = $this->form_validation->run(); + $_POST = array(); + + return $valid; } } From fa2a0c58eb0f6421e3819df8a8873b5a5e4ebb58 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Oct 2017 17:04:35 +0300 Subject: [PATCH 13/26] Fix #5297 --- system/database/DB_driver.php | 12 ++++++++---- user_guide_src/source/changelog.rst | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 0b13a2f82..c18701db3 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1926,15 +1926,19 @@ public function protect_identifiers($item, $prefix_single = FALSE, $protect_iden $i++; } + // dbprefix may've already been applied, with or without the identifier escaped + $ec = '(?'.preg_quote(is_array($this->_escape_char) ? $this->_escape_char[0] : $this->_escape_char).')?'; + isset($ec[0]) && $ec .= '?'; // Just in case someone has disabled escaping by forcing an empty escape character + // Verify table prefix and replace if necessary - if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0) + if ($this->swap_pre !== '' && preg_match('#^'.$ec.preg_quote($this->swap_pre).'#', $parts[$i])) { - $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]); + $parts[$i] = preg_replace('#^'.$ec.preg_quote($this->swap_pre).'(\S+?)#', '\\1'.$this->dbprefix.'\\2', $parts[$i]); } // We only add the table prefix if it does not already exist - elseif (strpos($parts[$i], $this->dbprefix) !== 0) + else { - $parts[$i] = $this->dbprefix.$parts[$i]; + preg_match('#^'.$ec.preg_quote($this->dbprefix).'#', $parts[$i]) OR $parts[$i] = $this->dbprefix.$parts[$i]; } // Put the parts back together diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index c762df744..d222e17fb 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -14,6 +14,7 @@ Bug fixes for 3.1.7 - Fixed a regression where :doc:`Database Results ` method ``field_data()`` returned incorrect type names. - Fixed a bug (#5278) - :doc:`URL Helper ` function :php:func:`auto_link()` didn't detect trailing slashes in URLs. - Fixed a regression (#5282) - :doc:`Query Builder ` method ``count_all_results()`` breaks ``ORDER BY`` clauses for subsequent queries. +- Fixed a bug (#5279) - :doc:`Query Builder ` didn't account for already escaped identifiers while applying database name prefixes. Version 3.1.6 ============= From d282d07dfba94b5395d1dd989bdb958c972bb7cf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Oct 2017 11:05:58 +0300 Subject: [PATCH 14/26] [ci skip] Use INTL_IDNA_VARIANT_UCS46 to convert non-ASCII domain names in emails Close #5300 --- system/libraries/Email.php | 6 ++++-- system/libraries/Form_validation.php | 3 ++- user_guide_src/source/changelog.rst | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 0e9cf0574..48726b769 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1036,7 +1036,8 @@ public function valid_email($email) { if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) { - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos)); + $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; + $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), $variant); } return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); @@ -1853,7 +1854,8 @@ protected function _validate_email_for_shell(&$email) { if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) { - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos)); + $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; + $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), $variant); } return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email)); diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 71d0e64b1..1619ec9a9 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1231,7 +1231,8 @@ public function valid_email($str) { if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches)) { - $str = $matches[1].'@'.idn_to_ascii($matches[2]); + $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; + $str = $matches[1].'@'.idn_to_ascii($matches[2], $variant); } return (bool) filter_var($str, FILTER_VALIDATE_EMAIL); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d222e17fb..647fe4817 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -7,6 +7,11 @@ Version 3.1.7 Release Date: Not Released +- General Changes + + - Updated :doc:`Form Validation Library ` rule ``valid_email`` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names. + - Updated :doc:`Email Library ` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names. + Bug fixes for 3.1.7 ------------------- From 211d23d31bd33d857377bdb13abdc104772164ff Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 25 Oct 2017 18:03:05 +0300 Subject: [PATCH 15/26] [ci skip] Merge pull request #5311 from gonzalo-massa/gonzalo-massa-patch-1 Download links for versions 2.2.4 to 2.2.6 added to docs --- user_guide_src/source/installation/downloads.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/installation/downloads.rst b/user_guide_src/source/installation/downloads.rst index bb7534d91..34e654078 100644 --- a/user_guide_src/source/installation/downloads.rst +++ b/user_guide_src/source/installation/downloads.rst @@ -17,6 +17,9 @@ Downloading CodeIgniter - `CodeIgniter v3.0.2 `_ - `CodeIgniter v3.0.1 `_ - `CodeIgniter v3.0.0 `_ +- `CodeIgniter v2.2.6 `_ +- `CodeIgniter v2.2.5 `_ +- `CodeIgniter v2.2.4 `_ - `CodeIgniter v2.2.3 `_ - `CodeIgniter v2.2.2 `_ - `CodeIgniter v2.2.1 `_ From 6cfc6a9c2a03207fdade86660e73aa4607b98f56 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 3 Nov 2017 13:38:13 +0200 Subject: [PATCH 16/26] [ci skip] Merge pull request #5321 from PrestigeT/documentation Fixed docblock on model function. Changed @param model from string to mixed --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 085c5b51d..fe2d43717 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -226,7 +226,7 @@ public function library($library, $params = NULL, $object_name = NULL) * * Loads and instantiates models. * - * @param string $model Model name + * @param mixed $model Model name * @param string $name An optional object name to assign to * @param bool $db_conn An optional database connection configuration to initialize * @return object From 35278338a21e6303a32fc3e3039b32d28e0d3fc5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 6 Nov 2017 13:04:47 +0200 Subject: [PATCH 17/26] [ci skip] Merge pull request #5326 from vinodselvin/patch-1 Bug in documentation --- contributing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contributing.md b/contributing.md index 2037e0424..8edb510cf 100644 --- a/contributing.md +++ b/contributing.md @@ -1,7 +1,7 @@ # Contributing to CodeIgniter -CodeIgniter is a community driven project and accepts contributions of code and documentation from the community. These contributions are made in the form of Issues or [Pull Requests](http://help.github.com/send-pull-requests/) on the [CodeIgniter repository](https://github.com/bcit-ci/CodeIgniter>) on GitHub. +CodeIgniter is a community driven project and accepts contributions of code and documentation from the community. These contributions are made in the form of Issues or [Pull Requests](http://help.github.com/send-pull-requests/) on the [CodeIgniter repository](https://github.com/bcit-ci/CodeIgniter) on GitHub. Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please check a few things first: @@ -92,4 +92,4 @@ If you are using command-line you can do the following: 2. `git pull codeigniter develop` 3. `git push origin develop` -Now your fork is up to date. This should be done regularly, or before you send a pull request at least. \ No newline at end of file +Now your fork is up to date. This should be done regularly, or before you send a pull request at least. From 44aa1ab0655283b67d6fdcb081803f25453dbc73 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Nov 2017 15:42:53 +0200 Subject: [PATCH 18/26] [ci skip] Deprecate extra parameters of the CAPTCHA helper --- system/helpers/captcha_helper.php | 8 ++++---- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/helpers/captcha_helper.rst | 12 ++++++++---- user_guide_src/source/installation/upgrade_317.rst | 13 +++++++++++++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 8f44806cc..b1a7eedd0 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -54,10 +54,10 @@ /** * Create CAPTCHA * - * @param array $data data for the CAPTCHA - * @param string $img_path path to create the image in - * @param string $img_url URL to the CAPTCHA image folder - * @param string $font_path server path to font + * @param array $data Data for the CAPTCHA + * @param string $img_path Path to create the image in (deprecated) + * @param string $img_url URL to the CAPTCHA image folder (deprecated) + * @param string $font_path Server path to font (deprecated) * @return string */ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 647fe4817..1793108d8 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -11,6 +11,7 @@ Release Date: Not Released - Updated :doc:`Form Validation Library ` rule ``valid_email`` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names. - Updated :doc:`Email Library ` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names. + - Deprecated usage of :doc:`CAPTCHA Helper ` function :php:func:`create_captcha()` with parameters other than ``$data``. Bug fixes for 3.1.7 ------------------- diff --git a/user_guide_src/source/helpers/captcha_helper.rst b/user_guide_src/source/helpers/captcha_helper.rst index 986c1d3e1..be1b20aaf 100644 --- a/user_guide_src/source/helpers/captcha_helper.rst +++ b/user_guide_src/source/helpers/captcha_helper.rst @@ -135,9 +135,9 @@ The following functions are available: .. php:function:: create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]]) :param array $data: Array of data for the CAPTCHA - :param string $img_path: Path to create the image in - :param string $img_url: URL to the CAPTCHA image folder - :param string $font_path: Server path to font + :param string $img_path: Path to create the image in (DEPRECATED) + :param string $img_url: URL to the CAPTCHA image folder (DEPRECATED) + :param string $font_path: Server path to font (DEPRECATED) :returns: array('word' => $word, 'time' => $now, 'image' => $img) :rtype: array @@ -161,4 +161,8 @@ The following functions are available: file extension. It will be a number like this: 1139612155.3422 The **word** is the word that appears in the captcha image, which if not - supplied to the function, will be a random string. \ No newline at end of file + supplied to the function, will be a random string. + + .. note:: Usage of the ``$img_path``, ``$img_url`` and ``$font_path`` + parameters is DEPRECATED. Provide them in the ``$data`` array + instead. diff --git a/user_guide_src/source/installation/upgrade_317.rst b/user_guide_src/source/installation/upgrade_317.rst index 93c37b687..dc1ee1868 100644 --- a/user_guide_src/source/installation/upgrade_317.rst +++ b/user_guide_src/source/installation/upgrade_317.rst @@ -12,3 +12,16 @@ Replace all files and directories in your *system/* directory. .. note:: If you have any custom developed files in these directories, please make copies of them first. + +Step 2: Remove usage of CAPTCHA helper extra parameters (deprecation) +===================================================================== + +The :doc:`CAPTCHA Helper <../helpers/captcha_helper>` function +:php:func:`create_captcha()` allows passing of its ``img_path``, ``img_url`` +and ``font_path`` options as the 2nd, 3rd and 4th parameters respectively. + +This kind of usage is now deprecated and you should just pass the options +in question as part of the first parameter array. + +.. note:: The functionality in question is still available, but you're + strongly encouraged to remove its usage sooner rather than later. From 4541bf930e715917622dc2d225bf5517f99db35a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Nov 2017 17:27:59 +0200 Subject: [PATCH 19/26] [ci skip] Fix patch for #5300 --- system/libraries/Email.php | 4 ++-- system/libraries/Form_validation.php | 2 +- user_guide_src/source/changelog.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 48726b769..3b1da8de0 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1037,7 +1037,7 @@ public function valid_email($email) if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) { $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), $variant); + $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, $variant); } return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); @@ -1855,7 +1855,7 @@ protected function _validate_email_for_shell(&$email) if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) { $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), $variant); + $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, $variant); } return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email)); diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 1619ec9a9..cd1d4a759 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1232,7 +1232,7 @@ public function valid_email($str) if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches)) { $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; - $str = $matches[1].'@'.idn_to_ascii($matches[2], $variant); + $str = $matches[1].'@'.idn_to_ascii($matches[2], 0, $variant); } return (bool) filter_var($str, FILTER_VALIDATE_EMAIL); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1793108d8..eb879c5a8 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -9,8 +9,8 @@ Release Date: Not Released - General Changes - - Updated :doc:`Form Validation Library ` rule ``valid_email`` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names. - - Updated :doc:`Email Library ` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names. + - Updated :doc:`Form Validation Library ` rule ``valid_email`` to use ``INTL_IDNA_VARIANT_UTS46`` for non-ASCII domain names. + - Updated :doc:`Email Library ` to use ``INTL_IDNA_VARIANT_UTS46`` for non-ASCII domain names. - Deprecated usage of :doc:`CAPTCHA Helper ` function :php:func:`create_captcha()` with parameters other than ``$data``. Bug fixes for 3.1.7 From df17a8940679bd7a087806052ae8e550fc1e249f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Nov 2017 16:40:47 +0200 Subject: [PATCH 20/26] Attempt PHP 7.2 tests on Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a7e5cdaeb..c235b3881 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 - hhvm env: @@ -31,6 +32,7 @@ script: php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 matrix: allow_failures: + - php: 7.2 - php: hhvm exclude: - php: hhvm From 4d1a9bd57c149b47183539677a64988916002cdf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Nov 2017 17:30:41 +0200 Subject: [PATCH 21/26] Don't try to run 'DB=mysql' tests on PHP 7.2 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c235b3881..044988998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,8 @@ matrix: env: DB=mysql - php: 7.1 env: DB=mysql + - php: 7.2 + env: DB=mysql branches: only: From 37134fd545ba39804b3f9fb6f51547d422d1e261 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Nov 2017 18:15:45 +0200 Subject: [PATCH 22/26] Move PHP 7.2 into the main testing matrix --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 044988998..8f7838bdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,6 @@ script: php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 matrix: allow_failures: - - php: 7.2 - php: hhvm exclude: - php: hhvm From 4fd2d49461cd871a99a63c51563b8aee3d023abd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Nov 2017 20:38:33 +0200 Subject: [PATCH 23/26] More on #5003 --- system/libraries/Email.php | 18 ++++++++++++------ system/libraries/Form_validation.php | 6 ++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 3b1da8de0..948cdb5c2 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1034,10 +1034,13 @@ public function validate_email($email) */ public function valid_email($email) { - if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) + if (function_exists('idn_to_ascii') && strpos($email, '@')) { - $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, $variant); + list($account, $domain) = explode('@', $email, 2); + $domain = is_php('5.4') + ? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) + : idn_to_ascii($domain); + $email = $account.'@'.$domain; } return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); @@ -1852,10 +1855,13 @@ protected function _spool_email() */ protected function _validate_email_for_shell(&$email) { - if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) + if (function_exists('idn_to_ascii') && strpos($email, '@')) { - $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, $variant); + list($account, $domain) = explode('@', $email, 2); + $domain = is_php('5.4') + ? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) + : idn_to_ascii($domain); + $email = $account.'@'.$domain; } return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email)); diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index cd1d4a759..73fb2dab9 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1231,8 +1231,10 @@ public function valid_email($str) { if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches)) { - $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003; - $str = $matches[1].'@'.idn_to_ascii($matches[2], 0, $variant); + $domain = is_php('5.4') + ? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46) + : idn_to_ascii($matches[2]); + $str = $matches[1].'@'.$domain; } return (bool) filter_var($str, FILTER_VALIDATE_EMAIL); From e176de516a86baef1f48f3bf9e63818985f6a034 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Nov 2017 18:16:58 +0200 Subject: [PATCH 24/26] Try testing on PHP master branch builds too (allowed failures) --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8f7838bdf..88c774283 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ php: - 7.0 - 7.1 - 7.2 + - master - hhvm env: @@ -33,6 +34,7 @@ script: php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 matrix: allow_failures: - php: hhvm + - php: master exclude: - php: hhvm env: DB=pgsql @@ -44,6 +46,8 @@ matrix: env: DB=mysql - php: 7.2 env: DB=mysql + - php: master + env: DB=mysql branches: only: From 8c9e51044d991868228dba8b9d5141998347dbfe Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 10 Nov 2017 15:02:42 +0200 Subject: [PATCH 25/26] Fix #5331 --- system/helpers/url_helper.php | 2 +- tests/codeigniter/helpers/url_helper_test.php | 9 +++++++++ user_guide_src/source/changelog.rst | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index f6fb7d9eb..489f2d44e 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -393,7 +393,7 @@ function safe_mailto($email, $title = '', $attributes = '') function auto_link($str, $type = 'both', $popup = FALSE) { // Find and replace any URLs. - if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w/?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { // Set our target HTML if using popup links. $target = ($popup) ? ' target="_blank"' : ''; diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index 5fbc364bf..83a8c0ec2 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -77,4 +77,13 @@ public function test_pull_675() } } + // -------------------------------------------------------------------- + + public function test_issue_5331() + { + $this->assertEquals( + 'this is some text that includes '.safe_mailto('www.email@domain.com').' which is causing an issue', + auto_link('this is some text that includes www.email@domain.com which is causing an issue') + ); + } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index eb879c5a8..1641f7c97 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -21,6 +21,7 @@ Bug fixes for 3.1.7 - Fixed a bug (#5278) - :doc:`URL Helper ` function :php:func:`auto_link()` didn't detect trailing slashes in URLs. - Fixed a regression (#5282) - :doc:`Query Builder ` method ``count_all_results()`` breaks ``ORDER BY`` clauses for subsequent queries. - Fixed a bug (#5279) - :doc:`Query Builder ` didn't account for already escaped identifiers while applying database name prefixes. +- Fixed a bug (#5331) - :doc:`URL Helper ` function :php:func:`auto_link()` converted e-mail addresses starting with 'www.' to both "url" and "email" links. Version 3.1.6 ============= From c9420849853a33a192c482e28c737e166d4fa698 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 10 Nov 2017 15:12:04 +0200 Subject: [PATCH 26/26] Close #5330 --- system/core/Loader.php | 8 +++++++- system/core/Model.php | 12 ------------ user_guide_src/source/changelog.rst | 1 + 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index fe2d43717..9813e99a9 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -303,6 +303,8 @@ public function model($model, $name = '', $db_conn = FALSE) { throw new RuntimeException($app_path."Model.php exists, but doesn't declare class CI_Model"); } + + log_message('info', 'CI_Model class loaded'); } elseif ( ! class_exists('CI_Model', FALSE)) { @@ -317,6 +319,8 @@ public function model($model, $name = '', $db_conn = FALSE) { throw new RuntimeException($app_path.$class.".php exists, but doesn't declare class ".$class); } + + log_message('info', config_item('subclass_prefix').'Model class loaded'); } } @@ -350,7 +354,9 @@ public function model($model, $name = '', $db_conn = FALSE) } $this->_ci_models[] = $name; - $CI->$name = new $model(); + $model = new $model(); + $CI->$name = $model; + log_message('info', 'Model "'.get_class($model).'" initialized'); return $this; } diff --git a/system/core/Model.php b/system/core/Model.php index c809e7b84..691053a9c 100644 --- a/system/core/Model.php +++ b/system/core/Model.php @@ -48,18 +48,6 @@ */ class CI_Model { - /** - * Class constructor - * - * @return void - */ - public function __construct() - { - log_message('info', 'Model Class Initialized'); - } - - // -------------------------------------------------------------------- - /** * __get magic * diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1641f7c97..1c35d9046 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -11,6 +11,7 @@ Release Date: Not Released - Updated :doc:`Form Validation Library ` rule ``valid_email`` to use ``INTL_IDNA_VARIANT_UTS46`` for non-ASCII domain names. - Updated :doc:`Email Library ` to use ``INTL_IDNA_VARIANT_UTS46`` for non-ASCII domain names. + - Updated :doc:`Loader Library ` method ``model()`` to log both ``CI_Model`` class loading and individual models' initialization. - Deprecated usage of :doc:`CAPTCHA Helper ` function :php:func:`create_captcha()` with parameters other than ``$data``. Bug fixes for 3.1.7