From 73c133c91dbd4ed8dba4496ce764fee90906fa62 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 12:14:16 +0200 Subject: [PATCH 1/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- phpBB/includes/functions_user.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d39dbed5ff..a44b92dd8d 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1470,8 +1470,11 @@ function user_ipwhois($ip) $ipwhois = ''; - // Limit the query to all possible flags (whois.arin.net) - $ip = 'z ' . $ip; + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) + { + // Limit the query to all possible flags (whois.arin.net) + $ip = 'z ' . $ip; + } if (($fsk = @fsockopen($whois_host, 43))) { From f8acf53f720742cde41c60ace20bcace649c9f84 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 13:28:23 +0200 Subject: [PATCH 2/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- phpBB/includes/functions_user.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a44b92dd8d..9e136cc1ff 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1470,16 +1470,10 @@ function user_ipwhois($ip) $ipwhois = ''; - if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) - { - // Limit the query to all possible flags (whois.arin.net) - $ip = 'z ' . $ip; - } - if (($fsk = @fsockopen($whois_host, 43))) { // CRLF as per RFC3912 - fputs($fsk, "$ip\r\n"); + fputs($fsk, "z $ip\r\n"); while (!feof($fsk)) { $ipwhois .= fgets($fsk, 1024); From af6eebaa1a49a7365a3a56322d05854db3ddcb23 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 13:33:46 +0200 Subject: [PATCH 3/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- phpBB/includes/functions_user.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9e136cc1ff..495f0dcacb 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1473,6 +1473,7 @@ function user_ipwhois($ip) if (($fsk = @fsockopen($whois_host, 43))) { // CRLF as per RFC3912 + // Z to limit the query to all possible flags (whois.arin.net) fputs($fsk, "z $ip\r\n"); while (!feof($fsk)) { From 3392f3aa091e21dca193c8b9c601a4d8c768b154 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:04:02 +0200 Subject: [PATCH 4/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- tests/functions_user/whois_test.php | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/functions_user/whois_test.php diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php new file mode 100644 index 0000000000..a9ff387728 --- /dev/null +++ b/tests/functions_user/whois_test.php @@ -0,0 +1,32 @@ +assertNotContains('Query terms are ambiguous', $ip_whois); + $this->assertNotContains('no entries found', $ip_whois); + $this->assertNotContains('ERROR', $ip_whois); + } +} From 7b062b76c7a2c8f2e090eafbddf831c53d77a63e Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:28:10 +0200 Subject: [PATCH 5/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- tests/functions_user/whois_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php index a9ff387728..eb20722926 100644 --- a/tests/functions_user/whois_test.php +++ b/tests/functions_user/whois_test.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; -class phpbb_functions_user_whois_test extends phpbb_functional_test_case +class phpbb_functions_user_whois_test extends phpbb_test_case { public function ips_data() { From 568a74e22c5d682c247d7e519e49cc141885c7d6 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:38:16 +0200 Subject: [PATCH 6/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- tests/functions_user/whois_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php index eb20722926..964594a57e 100644 --- a/tests/functions_user/whois_test.php +++ b/tests/functions_user/whois_test.php @@ -14,7 +14,7 @@ class phpbb_functions_user_whois_test extends phpbb_test_case public function ips_data() { return [ - ['2001:4860:4860::8888'], // Google public DNS + ['2001:4860:4860:0000:0000:0000:0000:8888'], // Google public DNS ['64.233.161.139'], // google.com ]; } From 4d5e8df8e69b17f17eb731b46edd57281248c0be Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:50:38 +0200 Subject: [PATCH 7/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- tests/functions_user/whois_test.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php index 964594a57e..1b964d7377 100644 --- a/tests/functions_user/whois_test.php +++ b/tests/functions_user/whois_test.php @@ -11,10 +11,23 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; class phpbb_functions_user_whois_test extends phpbb_test_case { - public function ips_data() + protected function setUp() + { + global $config, $phpbb_dispatcher, $user, $request, $symfony_request; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $config = new \phpbb\config\config([]); + $request = new phpbb_mock_request(); + $symfony_request = new \phpbb\symfony_request($request); + } + + public function ips_data() { return [ - ['2001:4860:4860:0000:0000:0000:0000:8888'], // Google public DNS + ['2001:4860:4860::8888'], // Google public DNS ['64.233.161.139'], // google.com ]; } From 642b77453071ab2707e4d714a842f83768eaf24a Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:10:00 +0200 Subject: [PATCH 8/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- tests/functions_user/whois_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php index 1b964d7377..ba8f54b7b1 100644 --- a/tests/functions_user/whois_test.php +++ b/tests/functions_user/whois_test.php @@ -13,7 +13,7 @@ class phpbb_functions_user_whois_test extends phpbb_test_case { protected function setUp() { - global $config, $phpbb_dispatcher, $user, $request, $symfony_request; + global $config, $phpbb_dispatcher, $user, $request, $symfony_request, $phpbb_root_path, $phpEx; $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); From 481ca6190e84651acaf9e8e83f69cf5aba905116 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:19:38 +0200 Subject: [PATCH 9/9] [ticket/16508] Fix WhoIs lookup PHPBB3-16508 --- tests/functions_user/whois_test.php | 45 ----------------------------- 1 file changed, 45 deletions(-) delete mode 100644 tests/functions_user/whois_test.php diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php deleted file mode 100644 index ba8f54b7b1..0000000000 --- a/tests/functions_user/whois_test.php +++ /dev/null @@ -1,45 +0,0 @@ -assertNotContains('Query terms are ambiguous', $ip_whois); - $this->assertNotContains('no entries found', $ip_whois); - $this->assertNotContains('ERROR', $ip_whois); - } -}