Loading core/includes/file.inc +7 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,13 @@ function file_url_transform_relative($file_url) { $host = $request->getHost(); $scheme = $request->getScheme(); $port = $request->getPort() ?: 80; // Files may be accessible on a different port than the web request. $file_url_port = parse_url($file_url, PHP_URL_PORT) ?? $port; if ($file_url_port != $port) { return $file_url; } if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { $http_host = $host; } Loading core/tests/Drupal/KernelTests/Core/File/UrlTransformRelativeTest.php +50 −35 Original line number Diff line number Diff line Loading @@ -41,41 +41,56 @@ public function testFileUrlTransformRelative($host, $port, $https, $url, $expect } public function providerFileUrlTransformRelative() { $data = []; $data[] = [ $data = [ 'http' => [ 'example.com', 80, '', 'http://example.com/page', '/page', ]; $data[] = [ ], 'https' => [ 'example.com', 443, 'on', 'https://example.com/page', '/page', ]; $data[] = [ ], 'http 8080' => [ 'example.com', 8080, '', 'https://example.com:8080/page', '/page', ]; $data[] = [ ], 'https 8443' => [ 'example.com', 8443, 'on', 'https://example.com:8443/page', '/page', ]; $data[] = [ ], 'http no dot' => [ 'example.com', 80, '', 'http://exampleXcom/page', 'http://exampleXcom/page', ], 'http files on different port than the web request' => [ 'example.com', 80, '', 'http://example.com:9000/page', 'http://example.com:9000/page', ], 'https files on different port than the web request' => [ 'example.com', 443, 'on', 'https://example.com:8443/page', 'https://example.com:8443/page', ], ]; return $data; } Loading Loading
core/includes/file.inc +7 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,13 @@ function file_url_transform_relative($file_url) { $host = $request->getHost(); $scheme = $request->getScheme(); $port = $request->getPort() ?: 80; // Files may be accessible on a different port than the web request. $file_url_port = parse_url($file_url, PHP_URL_PORT) ?? $port; if ($file_url_port != $port) { return $file_url; } if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { $http_host = $host; } Loading
core/tests/Drupal/KernelTests/Core/File/UrlTransformRelativeTest.php +50 −35 Original line number Diff line number Diff line Loading @@ -41,41 +41,56 @@ public function testFileUrlTransformRelative($host, $port, $https, $url, $expect } public function providerFileUrlTransformRelative() { $data = []; $data[] = [ $data = [ 'http' => [ 'example.com', 80, '', 'http://example.com/page', '/page', ]; $data[] = [ ], 'https' => [ 'example.com', 443, 'on', 'https://example.com/page', '/page', ]; $data[] = [ ], 'http 8080' => [ 'example.com', 8080, '', 'https://example.com:8080/page', '/page', ]; $data[] = [ ], 'https 8443' => [ 'example.com', 8443, 'on', 'https://example.com:8443/page', '/page', ]; $data[] = [ ], 'http no dot' => [ 'example.com', 80, '', 'http://exampleXcom/page', 'http://exampleXcom/page', ], 'http files on different port than the web request' => [ 'example.com', 80, '', 'http://example.com:9000/page', 'http://example.com:9000/page', ], 'https files on different port than the web request' => [ 'example.com', 443, 'on', 'https://example.com:8443/page', 'https://example.com:8443/page', ], ]; return $data; } Loading