From d00b9cd2fe18facd10aaeda1442437bef9c3e62e Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 20 Sep 2023 20:22:36 +0200 Subject: [PATCH] fix: Resolve some psalm issues Signed-off-by: Ferdinand Thiessen --- apps/dav/lib/Connector/Sabre/CorsPlugin.php | 7 ++++++- lib/private/Route/Router.php | 2 +- lib/public/Util.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/CorsPlugin.php b/apps/dav/lib/Connector/Sabre/CorsPlugin.php index 236e3000829..198bc20a7eb 100644 --- a/apps/dav/lib/Connector/Sabre/CorsPlugin.php +++ b/apps/dav/lib/Connector/Sabre/CorsPlugin.php @@ -69,9 +69,10 @@ class CorsPlugin extends ServerPlugin { return; } $originHeader = $request->getHeader('Origin'); - if ($this->ignoreOriginHeader($originHeader)) { + if ($originHeader === null || $this->ignoreOriginHeader($originHeader)) { return; } + try { if (Util::isSameDomain($originHeader, $request->getAbsoluteUrl())) { return; @@ -86,6 +87,10 @@ class CorsPlugin extends ServerPlugin { $this->server->on('beforeMethod:OPTIONS', [$this, 'setOptionsRequestHeaders'], 5); } + /** + * @param \Throwable $ex The thrown exception + * @return void + */ public function onException(\Throwable $ex) { $this->setCorsHeaders($this->server->httpRequest, $this->server->httpResponse); } diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index 972fce81a8e..d74fb675088 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -287,7 +287,7 @@ class Router implements IRouter { // Reach here if it's valid $response = new \OC\OCS\Result(null, 100, 'OPTIONS request successful'); - $response = \OC_Response::setOptionsRequestHeaders($response); + \OC_Response::setOptionsRequestHeaders($response, $this->config); \OC_API::respond($response, \OC_API::requestedFormat()); // Return since no more processing for an OPTIONS request is required diff --git a/lib/public/Util.php b/lib/public/Util.php index def43b34c48..9e1160ccaf5 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -650,7 +650,7 @@ class Util { $host = \strtolower($parts['host']); $port = $parts['port'] ?? null; - if ($port === null || $port === '') { + if ($port === null || $port === 0) { if ($protocol === 'http') { $port = 80; } elseif ($protocol === 'https') { -- 2.39.5