Merge pull request #58350 from nextcloud/regressionEmptyPort

fix(sftp): Handle empty port parameter to allow host-defined ports
This commit is contained in:
Git'Fellow 2026-02-16 10:13:38 +01:00 committed by GitHub
commit f06133bf13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,9 +68,12 @@ class SFTP extends Common {
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');