Skip to content

Commit b1e71ae

Browse files
committed
fix(sftp): Handle empty port parameter to allow host-defined ports
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent cf1c70c commit b1e71ae

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • apps/files_external/lib/Lib/Storage

apps/files_external/lib/Lib/Storage/SFTP.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ public function __construct(array $parameters) {
6868
Stream::register();
6969

7070
$parsedHost = $this->splitHost($parameters['host']);
71-
7271
$this->host = $parsedHost[0];
73-
$this->port = $parameters['port'] ?? $parsedHost[1];
72+
73+
// Handle empty port parameter to allow host-defined ports
74+
// and ensure strictly numeric ports
75+
$parsedPort = $parameters['port'] ?? null;
76+
$this->port = (int)(is_numeric($parsedPort) ? $parsedPort : $parsedHost[1]);
7477

7578
if (!isset($parameters['user'])) {
7679
throw new \UnexpectedValueException('no authentication parameters specified');

0 commit comments

Comments
 (0)