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)
3636 curl_setopt ($ curl , CURLOPT_URL , $ url );
3737 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , 1 );
3838 curl_setopt ($ curl , CURLOPT_HTTPHEADER , $ headers );
39- $ output = json_decode (curl_exec ($ curl ), true );
39+ $ keys = json_decode (curl_exec ($ curl ), false );
4040 curl_close ($ curl );
4141
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 [];
4547 }
46-
47- return $ out ;
48+ return array_map (function ($ x ){return $ x ->key ;}, $ keys );
4849 }
4950
5051 public static function testValidSSHKey ($ key_str )
Original file line number Diff line number Diff line change 3838 break ;
3939 case "github " :
4040 $ gh_user = $ _POST ["gh_user " ];
41- if (empty ($ gh_user )) {
42- break ;
43- }
4441 $ keys = UnitySite::getGithubKeys ($ gh_user );
4542 foreach ($ keys as $ key ) {
4643 if (UnitySite::testValidSSHKey ($ key )) {
You can’t perform that action at this time.
0 commit comments