From e31f10e648a563b34f1346459f34bd294c08f492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20d=27Anterroches?= Date: Tue, 1 Feb 2011 20:58:24 +0100 Subject: [PATCH] Fixed error in the cron job if a key has a bad format. --- src/IDF/Key.php | 2 +- src/IDF/Plugin/SyncGit/Cron.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/IDF/Key.php b/src/IDF/Key.php index 2320d8f..8896bdc 100644 --- a/src/IDF/Key.php +++ b/src/IDF/Key.php @@ -84,7 +84,7 @@ class IDF_Key extends Pluf_Model return array('ssh', $m[2], $m[1]); } - throw new Exception('invalid or unknown key data detected'); + throw new Exception(__('Invalid or unknown key data detected.')); } /** diff --git a/src/IDF/Plugin/SyncGit/Cron.php b/src/IDF/Plugin/SyncGit/Cron.php index cbcf8f6..f47063d 100644 --- a/src/IDF/Plugin/SyncGit/Cron.php +++ b/src/IDF/Plugin/SyncGit/Cron.php @@ -48,7 +48,13 @@ class IDF_Plugin_SyncGit_Cron $out = ''; $keys = Pluf::factory('IDF_Key')->getList(array('view'=>'join_user')); foreach ($keys as $key) { - if ($key->getType() == 'ssh' and preg_match('/^[a-zA-Z][a-zA-Z0-9_.-]*(@[a-zA-Z][a-zA-Z0-9.-]*)?$/', $key->login)) { + try { + $key_type = $key->getType(); + } catch (Exception $e) { + // The key is a bad key, skip it + continue; + } + if ($key_type == 'ssh' and preg_match('/^[a-zA-Z][a-zA-Z0-9_.-]*(@[a-zA-Z][a-zA-Z0-9.-]*)?$/', $key->login)) { $content = trim(str_replace(array("\n", "\r"), '', $key->content)); $out .= sprintf($template, $cmd, $key->login, $content)."\n"; }