Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13980107
D9701.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D9701.diff
View Options
diff --git a/src/applications/settings/panel/PhabricatorSettingsPanelSSHKeys.php b/src/applications/settings/panel/PhabricatorSettingsPanelSSHKeys.php
--- a/src/applications/settings/panel/PhabricatorSettingsPanelSSHKeys.php
+++ b/src/applications/settings/panel/PhabricatorSettingsPanelSSHKeys.php
@@ -379,22 +379,29 @@
private static function parsePublicKey($entire_key) {
$parts = str_replace("\n", '', trim($entire_key));
- $parts = preg_split('/\s+/', $parts);
- if (count($parts) == 2) {
- $parts[] = ''; // Add an empty comment part.
- } else if (count($parts) == 3) {
- // This is the expected case.
- } else {
- if (preg_match('/private\s*key/i', $entire_key)) {
- // Try to give the user a better error message if it looks like
- // they uploaded a private key.
- throw new Exception(
- pht('Provide your public key, not your private key!'));
- } else {
+ // The third field (the comment) can have spaces in it, so split this
+ // into a maximum of three parts.
+ $parts = preg_split('/\s+/', $parts, 3);
+
+ if (preg_match('/private\s*key/i', $entire_key)) {
+ // Try to give the user a better error message if it looks like
+ // they uploaded a private key.
+ throw new Exception(
+ pht('Provide your public key, not your private key!'));
+ }
+
+ switch (count($parts)) {
+ case 1:
throw new Exception(
pht('Provided public key is not properly formatted.'));
- }
+ case 2:
+ // Add an empty comment part.
+ $parts[] = '';
+ break;
+ case 3:
+ // This is the expected case.
+ break;
}
list($type, $body, $comment) = $parts;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 20 2024, 8:30 AM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714179
Default Alt Text
D9701.diff (1 KB)
Attached To
Mode
D9701: Fix validation of SSH keys with spaces in the comment field
Attached
Detach File
Event Timeline
Log In to Comment