diff --git a/installation/model/database.php b/installation/model/database.php index 7e554c4a50b98..8f70da01c9735 100644 --- a/installation/model/database.php +++ b/installation/model/database.php @@ -158,15 +158,11 @@ public function initialise($options) $shouldCheckLocalhost = getenv('JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK') !== '1'; - // Per Default allowed DB Hosts - $localhost = array( - 'localhost', - '127.0.0.1', - '::1', - ); - - // Check the security file if the db_host is not localhost / 127.0.0.1 / ::1 - if ($shouldCheckLocalhost && !in_array($options->db_host, $localhost)) + // Per default allowed DB hosts: localhost / 127.0.0.1 / ::1 (optionally with port) + $localhost = '/^(((localhost|127\.0\.0\.1|\[\:\:1\])(\:[1-9]{1}[0-9]{0,4})?)|(\:\:1))$/'; + + // Check the security file if now switched off and the db_host is not one of the allowed hosts + if ($shouldCheckLocalhost && preg_match($localhost, $options->db_host) !== 1) { $remoteDbFileTestsPassed = JFactory::getSession()->get('remoteDbFileTestsPassed', false);