From 74b1de0bc244db56fd105e91c9e9f453332d9eb6 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sat, 27 Sep 2025 17:07:36 -0500 Subject: [PATCH] [ticket/17477] Support non-prefixed whois servers Referral servers lacking the whois:// prefix are not currently supported. This ticket adds support for those servers. At the moment, this is mainly an issue for RIPE entries on ARIN. They will now be detected and followed. PHPBB-17477 --- phpBB/includes/functions_user.php | 3 ++- tests/functions_user/whois_test.php | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a87b79d3a6..1c615fa9d0 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1482,7 +1482,8 @@ function user_ipwhois($ip) $match = array(); // Test for referrals from $whois_host to other whois databases, roll on rwhois - if (preg_match('#ReferralServer:[\x20]*whois://(.+)#im', $ipwhois, $match)) + // Search for referral servers with or without the "whois://" prefix + if (preg_match('#ReferralServer:[\x20]*whois://(.+)#im', $ipwhois, $match) || preg_match('#ReferralServer:[\x20]*([^/]+)$#im', $ipwhois, $match)) { if (strpos($match[1], ':') !== false) { diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php index 4dd72311bb..70873f6b1a 100644 --- a/tests/functions_user/whois_test.php +++ b/tests/functions_user/whois_test.php @@ -33,8 +33,10 @@ class phpbb_functions_user_whois_test extends phpbb_test_case public function ips_data() { return [ - ['2001:4860:4860::8888'], // Google public DNS - ['64.233.161.139'], // google.com + ['2001:4860:4860::8888'], // Google public DNS (ARIN) + ['64.233.161.139'], // google.com (ARIN) + ['1.1.1.1'], // Cloudflare (APNIC via whois:// referral) + ['213.133.116.44'], // Hetzner (RIPE via non-whois:// referral) ]; } @@ -47,5 +49,6 @@ class phpbb_functions_user_whois_test extends phpbb_test_case $this->assertStringNotContainsString('Query terms are ambiguous', $ip_whois); $this->assertStringNotContainsString('no entries found', $ip_whois); $this->assertStringNotContainsString('ERROR', $ip_whois); + $this->assertStringNotContainsString('Allocated to RIPE NCC', $ip_whois); // This only shows if the referral isn't found } }