From 3eb21888da8735cd3c922209f44cb87691c19ce0 Mon Sep 17 00:00:00 2001 From: janw Date: Fri, 10 Jun 2005 11:45:43 +0000 Subject: [PATCH] Modified certificate check. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@666 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/personal/generic/class_user.inc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index b4ae7f07b..ab8d5d69d 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -341,12 +341,12 @@ class user extends plugin /* for all certificates do */ foreach (array ("userCertificate", "userSMIMECertificate", "userPKCS12") as $val){ - + /* Check for clean upload */ - if (defined($val) && $val != '' && - preg_match('/\s+/', $_FILES[$val."_file"]['name']) && + if (array_key_exists($val."_file", $_FILES) && + array_key_exists('name', $_FILES[$val."_file"]) && + $_FILES[$val."_file"]['name'] != "" && is_uploaded_file($_FILES[$val."_file"]['tmp_name'])) { - $this->set_cert("$val", $_FILES[$val."_file"]['tmp_name']); } } @@ -931,12 +931,12 @@ class user extends plugin /* Check for reserved characers */ if (preg_match ('/[,+"<>;]/', $this->givenName)){ $message[]= _("The field 'Given name' contains invalid characters."); - } - if (preg_match ('/[,+"<>;]/', $this->sn)){ - $message[]= _("The field 'Name' contains invalid characters."); - } + } + if (preg_match ('/[,+"<>;]/', $this->sn)){ + $message[]= _("The field 'Name' contains invalid characters."); + } - return $message; + return $message; } @@ -1044,12 +1044,13 @@ class user extends plugin /* Load certificate from file to object */ function set_cert($cert, $filename) { - if($fd = fopen ($filename, "rb")) { + $fd = fopen ($filename, "rb"); + if (filesize($filename)>0) { $this->$cert= fread ($fd, filesize ($filename)); fclose ($fd); $this->is_modified= TRUE; } else { - print_red(_("Cannot open the specified file!")); + print_red(_("Could not open specified certificate!")); } } -- 2.30.2