fix: Resolve some psalm issues

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2023-09-20 20:22:36 +02:00
parent bcfaa850f3
commit d00b9cd2fe
3 changed files with 8 additions and 3 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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') {