Skip to content

Commit 18b1f54

Browse files
committed
simpler regex, valueerror
1 parent d6b5a95 commit 18b1f54

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

resources/lib/UnityUser.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,17 @@ public function getSSHKeys(): array
300300
return $result;
301301
}
302302

303+
/*
304+
key must take the form "KEY_TYPE KEY_DATA OPTIONAL_COMMENT"
305+
https://github.com/phpseclib/phpseclib/issues/2117
306+
*/
303307
private static function removeSSHKeyOptionalCommentSuffix(string $key): string
304308
{
305309
$matches = [];
306-
// (leadingWhitespace? word whitespace word) whitespace (words) trailingWhitespace?
307-
if (preg_match("/^(\s*\S+\s+\S+)\s+(\S.*\S)\s*$/", $key, $matches)) {
310+
if (preg_match("/^(\S+\s+\S+)/", $key, $matches)) {
308311
return $matches[1];
309312
} else {
310-
return $key;
313+
throw new \ValueError("invalid SSH key: $key");
311314
}
312315
}
313316

0 commit comments

Comments
 (0)