diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index e275e5b497b08..6504ea610f345 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -68,9 +68,12 @@ public function __construct(array $parameters) { Stream::register(); $parsedHost = $this->splitHost($parameters['host']); - $this->host = $parsedHost[0]; - $this->port = $parameters['port'] ?? $parsedHost[1]; + + // Handle empty port parameter to allow host-defined ports + // and ensure strictly numeric ports + $parsedPort = $parameters['port'] ?? null; + $this->port = (int)(is_numeric($parsedPort) ? $parsedPort : $parsedHost[1]); if (!isset($parameters['user'])) { throw new \UnexpectedValueException('no authentication parameters specified');