Skip to content

Commit 835e7ea

Browse files
authored
Merge pull request clue#15 from clue-labs/fix-invalid-url
Fix error reporting when parsing invalid SOCKS server URL
2 parents dcaddcc + e925010 commit 835e7ea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/SshProcessConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($uri, LoopInterface $loop)
3434
// URI must use optional ssh:// scheme, must contain host and neither pass nor target must start with dash
3535
$parts = \parse_url((\strpos($uri, '://') === false ? 'ssh://' : '') . $uri);
3636
$pass = isset($parts['pass']) ? \rawurldecode($parts['pass']) : null;
37-
$target = (isset($parts['user']) ? \rawurldecode($parts['user']) . '@' : '') . $parts['host'];
37+
$target = (isset($parts['user']) ? \rawurldecode($parts['user']) . '@' : '') . (isset($parts['host']) ? $parts['host'] : '');
3838
if (!isset($parts['scheme'], $parts['host']) || $parts['scheme'] !== 'ssh' || (isset($pass[0]) && $pass[0] === '-') || $target[0] === '-') {
3939
throw new \InvalidArgumentException('Invalid SSH server URI');
4040
}

src/SshSocksConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($uri, LoopInterface $loop)
4545
// URI must use optional ssh:// scheme, must contain host and neither pass nor target must start with dash
4646
$parts = \parse_url((\strpos($uri, '://') === false ? 'ssh://' : '') . $uri);
4747
$pass = isset($parts['pass']) ? \rawurldecode($parts['pass']) : null;
48-
$target = (isset($parts['user']) ? \rawurldecode($parts['user']) . '@' : '') . $parts['host'];
48+
$target = (isset($parts['user']) ? \rawurldecode($parts['user']) . '@' : '') . (isset($parts['host']) ? $parts['host'] : '');
4949
if (!isset($parts['scheme'], $parts['host']) || $parts['scheme'] !== 'ssh' || (isset($pass[0]) && $pass[0] === '-') || $target[0] === '-') {
5050
throw new \InvalidArgumentException('Invalid SSH server URI');
5151
}

0 commit comments

Comments
 (0)