From 7311517d65f43a6a3acfe496eea661ee2bb64677 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 13 Sep 2021 12:34:42 +0300 Subject: [PATCH] Fixed incorrect port :0 with nginx unix socket setup [#3439] --- CHANGELOG.md | 1 + system/src/Grav/Common/Uri.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 130dae61d..221b5c1bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fixed escaping in PageIndex::getLevelListing() * Fixed validation of `number` type [#3433](https://github.com/getgrav/grav/issues/3433) * Fixed excessive `security.yaml` file creation [#3432](https://github.com/getgrav/grav/issues/3432) + * Fixed incorrect port :0 with nginx unix socket setup [#3439](https://github.com/getgrav/grav/issues/3439) # v1.7.20 ## 09/01/2021 diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index c7f71048e..de325bbe2 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -1261,7 +1261,7 @@ class Uri $this->port = null; } - if ($this->hasStandardPort()) { + if ($this->port === 0 || $this->hasStandardPort()) { $this->port = null; } @@ -1314,11 +1314,13 @@ class Uri if ($parts === false) { throw new RuntimeException('Malformed URL: ' . $url); } + $port = (int)($parts['port'] ?? 0); + $this->scheme = $parts['scheme'] ?? null; $this->user = $parts['user'] ?? null; $this->password = $parts['pass'] ?? null; $this->host = $parts['host'] ?? null; - $this->port = isset($parts['port']) ? (int)$parts['port'] : null; + $this->port = $port ?: null; $this->path = $parts['path'] ?? ''; $this->query = $parts['query'] ?? ''; $this->fragment = $parts['fragment'] ?? null;