File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -36,15 +36,16 @@ public static function getGithubKeys($username)
36
36
curl_setopt ($ curl , CURLOPT_URL , $ url );
37
37
curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , 1 );
38
38
curl_setopt ($ curl , CURLOPT_HTTPHEADER , $ headers );
39
- $ output = json_decode (curl_exec ($ curl ), true );
39
+ $ keys = json_decode (curl_exec ($ curl ), false );
40
40
curl_close ($ curl );
41
41
42
- $ out = array ();
43
- foreach ($ output as $ value ) {
44
- array_push ($ out , $ value ["key " ]);
42
+ // normally returns array of objects each with a ->key attribute
43
+ // if bad URL or no such user, returns status=404 object
44
+ // if no keys, returns []
45
+ if ((!is_array ($ keys )) || (count ($ keys ) == 0 )) {
46
+ return [];
45
47
}
46
-
47
- return $ out ;
48
+ return array_map (function ($ x ){return $ x ->key ;}, $ keys );
48
49
}
49
50
50
51
public static function testValidSSHKey ($ key_str )
Original file line number Diff line number Diff line change 38
38
break ;
39
39
case "github " :
40
40
$ gh_user = $ _POST ["gh_user " ];
41
- if (empty ($ gh_user )) {
42
- break ;
43
- }
44
41
$ keys = UnitySite::getGithubKeys ($ gh_user );
45
42
foreach ($ keys as $ key ) {
46
43
if (UnitySite::testValidSSHKey ($ key )) {
You can’t perform that action at this time.
0 commit comments