Skip to content

Commit c00ff8e

Browse files
committed
redirection to different domain must not keep previous port
1 parent 76730e3 commit c00ff8e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
### Fixed
66

7-
- Fixes false positive circular detection in RedirectPlugin in cases when target location does not contain path
7+
- [RedirectPlugin] Fixed handling of redirection to different domain with default port
8+
- [RedirectPlugin] Fixed false positive circular detection in RedirectPlugin in cases when target location does not contain path
89

910
## 2.5.0 - 2021-11-26
1011

src/Plugin/RedirectPlugin.php

+2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ private function createUri(ResponseInterface $redirectResponse, RequestInterface
247247

248248
if (array_key_exists('port', $parsedLocation)) {
249249
$uri = $uri->withPort($parsedLocation['port']);
250+
} elseif (array_key_exists('host', $parsedLocation)) {
251+
$uri = $uri->withPort(null);
250252
}
251253

252254
return $uri;

tests/Plugin/RedirectPluginTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ function () {}
3030
* @testWith ["https://example.com/path?query=value", "https://example.com?query=value", "https://example.com?query=value"]
3131
* ["https://example.com/path?query=value", "https://example.com/?query=value", "https://example.com/?query=value"]
3232
* ["https://example.com", "https://example.com?query=value", "https://example.com?query=value"]
33+
* ["https://example.com:8000", "https://foo.com?query=value", "https://foo.com?query=value"]
34+
* ["https://example.com:8000", "/path?query=value", "https://example.com:8000/path?query=value"]
3335
*/
3436
public function testTargetUriMappingFromLocationHeader(string $originalUri, string $locationUri, string $targetUri): void
3537
{

0 commit comments

Comments
 (0)