diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc index 4d560e7d361d1240662e774032a91ac8aea6a8fe..a16dbe82ce5a2e932ec10fbc1c7566d780091657 100644 --- a/core/modules/language/language.negotiation.inc +++ b/core/modules/language/language.negotiation.inc @@ -220,6 +220,11 @@ function language_from_url($languages) { break; case LANGUAGE_NEGOTIATION_URL_DOMAIN: + // Get only the host, not the port. + $http_host= $_SERVER['HTTP_HOST']; + if (strpos($http_host, ':') !== FALSE) { + $http_host = current(explode(':', $http_host)); + } $domains = language_negotiation_url_domains(); foreach ($languages as $language) { // Skip the check if the language doesn't have a domain. @@ -228,7 +233,7 @@ function language_from_url($languages) { // the hostname. $host = 'http://' . str_replace(array('http://', 'https://'), '', $domains[$language->langcode]); $host = parse_url($host, PHP_URL_HOST); - if ($_SERVER['HTTP_HOST'] == $host) { + if ($http_host == $host) { $language_url = $language->langcode; break; } diff --git a/core/modules/language/language.test b/core/modules/language/language.test index d48f2a9e82066d59ce9acc85eb9d856dee0b129f..d931dc6a995715cdb6a007e81ba3d3576939fd2f 100644 --- a/core/modules/language/language.test +++ b/core/modules/language/language.test @@ -706,7 +706,7 @@ class LanguageUILanguageNegotiationTestCase extends WebTestBase { array( 'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_DEFAULT), 'language_negotiation_url_part' => LANGUAGE_NEGOTIATION_URL_DOMAIN, - 'language_test_domain' => $language_domain, + 'language_test_domain' => $language_domain . ':88', 'path' => 'admin/config', 'expect' => $language_string, 'expected_method_id' => LANGUAGE_NEGOTIATION_URL,