c770d2f0ca9fd3e3e741ba0f9642841ce508365d
Author: gwoo
Date: 2009-12-15 15:35:37 -0800
diff --git a/models/ssh_key.php b/models/ssh_key.php
index 8a6def5..893ccf1 100644
--- a/models/ssh_key.php
+++ b/models/ssh_key.php
@@ -232,7 +232,11 @@ class SshKey extends AppModel {
*/
function __strip($key) {
return preg_replace('/==(.+)$/', '==',
- str_replace(array("\n", "\r", "\t", " "), array("", "", ""), trim($key))
+ str_replace(
+ array("\n", "\r", "\t", " ", 'ssh-rsa', 'ssh-dss'),
+ array("", "", "", "", 'ssh-rsa ', 'ssh-dss '),
+ trim($key)
+ )
);
}
}
diff --git a/tests/cases/models/ssh_key.test.php b/tests/cases/models/ssh_key.test.php
index f531c9d..302c4a7 100644
--- a/tests/cases/models/ssh_key.test.php
+++ b/tests/cases/models/ssh_key.test.php
@@ -50,7 +50,7 @@ class SshKeyTestCase extends CakeTestCase {
$SshKey->set(array(
'type' => 'Git',
'username' => 'gwoo',
- 'content' => 'this is a key',
+ 'content' => 'ssh-rsa this is a key',
));
$this->assertTrue($SshKey->save());
@@ -58,7 +58,7 @@ class SshKeyTestCase extends CakeTestCase {
$SshKey->set(array(
'type' => 'Git',
'username' => 'gwoo',
- 'content' => 'this is another key',
+ 'content' => 'ssh-rsa this is another key',
));
$this->assertTrue($SshKey->save());
@@ -73,8 +73,8 @@ class SshKeyTestCase extends CakeTestCase {
));
$expected = array(
- 'thisisakey',
- 'thisisanotherkey'
+ 'ssh-rsa thisisakey',
+ 'ssh-rsa thisisanotherkey'
);
$this->assertEqual($result, $expected);
@@ -85,7 +85,7 @@ class SshKeyTestCase extends CakeTestCase {
$result = $SshKey->delete(array(
'type' => 'Git', 'username' => 'gwoo',
- 'content' => 'thisisakey'
+ 'content' => 'ssh-rsa thisisakey'
));
$this->assertTrue($result);
@@ -97,7 +97,7 @@ class SshKeyTestCase extends CakeTestCase {
));
$expected = array(
- 'thisisanotherkey'
+ 'ssh-rsa thisisanotherkey'
);
$this->assertEqual($result, $expected);
@@ -112,7 +112,7 @@ class SshKeyTestCase extends CakeTestCase {
$SshKey->set(array(
'type' => 'Git',
'username' => 'gwoo',
- 'content' => 'this is a key== something',
+ 'content' => 'ssh-rsa this is a key== something',
));
$this->assertTrue($SshKey->save());
@@ -121,7 +121,7 @@ class SshKeyTestCase extends CakeTestCase {
'type' => 'Git', 'username' => 'gwoo',
));
$expected = array(
- 'thisisakey=='
+ 'ssh-rsa thisisakey=='
);
$this->assertEqual($result, $expected);
