From 9fd9248a2d712d5ae95bf2e6c6cd036e6b522cbb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 19 Jul 2016 14:04:17 +0300 Subject: Fix #4679 --- system/core/Input.php | 4 ++-- tests/codeigniter/core/Input_test.php | 6 ++++++ user_guide_src/source/changelog.rst | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index 50ca047e8..b81d51ebf 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -519,9 +519,9 @@ class CI_Input { if ($separator === ':') { $netaddr = explode(':', str_replace('::', str_repeat(':', 9 - substr_count($netaddr, ':')), $netaddr)); - for ($i = 0; $i < 8; $i++) + for ($j = 0; $j < 8; $j++) { - $netaddr[$i] = intval($netaddr[$i], 16); + $netaddr[$i] = intval($netaddr[$j], 16); } } else diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index c56900d22..e1f4011b5 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -261,6 +261,12 @@ class Input_test extends CI_TestCase { $_SERVER['REMOTE_ADDR'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'; $this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address()); + $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', '0::/32'); + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.7'; + $_SERVER['REMOTE_ADDR'] = '0000:0000:0000:0000:0000:0000:0000:0001'; + $this->assertEquals('127.0.0.7', $this->input->ip_address()); + $this->input->ip_address = FALSE; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d39900c67..ef8b5d6ce 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -40,6 +40,7 @@ Bug fixes for 3.0.7 - Fixed a bug (#4674) - :doc:`Database ` driver 'dblib' triggered E_WARNING messages while connecting. - Fixed a bug (#4678) - :doc:`Database Forge ` tried to use unsupported `IF NOT EXISTS` clause when creating tables on Oracle. - Fixed a bug (#4691) - :doc:`File Uploading Library ` method ``data()`` returns wrong 'raw_name' when the filename extension is also contained in the raw filename. +- Fixed a bug (#4679) - :doc:`Input Library ` method ``ip_address()`` errors with a matching ``$config['proxy_ips']`` IPv6 address. Version 3.0.6 ============= -- cgit v1.2.3-24-g4f1b