From: Paul L. <pdo...@us...> - 2006-11-13 22:54:59
|
Update of /cvsroot/squirrelmail/squirrelmail/functions In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv22709/functions Modified Files: imap_general.php Log Message: Allow sqimap_login() to return error string when connection fails; would be nice if we had an error code system instead; the extent to which HTML is buried in error messages in the core like here is indicative of just how far away SM's architecture is from a good modularized system that is truly ready for t12n and a good API. Index: imap_general.php =================================================================== RCS file: /cvsroot/squirrelmail/squirrelmail/functions/imap_general.php,v retrieving revision 1.242 retrieving revision 1.243 diff -u -w -r1.242 -r1.243 --- imap_general.php 11 Nov 2006 08:24:25 -0000 1.242 +++ imap_general.php 11 Nov 2006 20:05:23 -0000 1.243 @@ -760,8 +760,10 @@ * 0 = do not hide * 1 = show no errors (just exit) * 2 = show no errors (return FALSE) - * @return mixed The IMAP connection stream, or FALSE if $hide is set to 2 - * and the connection fails. + * 3 = show no errors (return error string) + * @return mixed The IMAP connection stream, or if the connection fails, + * FALSE if $hide is set to 2 or an error string if $hide + * is set to 3. */ function sqimap_login ($username, $password, $imap_server_address, $imap_port, $hide) { global $color, $squirrelmail_language, $onetimepad, $use_imap_tls, @@ -902,14 +904,17 @@ /* If the connection was not successful, lets see why */ if ($response != 'OK') { - if (!$hide) { + if (!$hide || $hide == 3) { +//FIXME: UUURG... We don't want HTML in error messages, should also do html sanitizing of error messages elsewhere; should't assume output is destined for an HTML browser here if ($response != 'NO') { /* "BAD" and anything else gets reported here. */ $message = htmlspecialchars($message); set_up_language($squirrelmail_language, true); if ($response == 'BAD') { + if ($hide == 3) return sprintf(_("Bad request: %s"), $message); $string = sprintf (_("Bad request: %s")."<br />\r\n", $message); } else { + if ($hide == 3) return sprintf(_("Unknown error: %s"), $message); $string = sprintf (_("Unknown error: %s") . "<br />\n", $message); } if (isset($read) && is_array($read)) { @@ -937,6 +942,7 @@ sqsetcookieflush(); /* terminate the session nicely */ sqimap_logout($imap_stream); + if ($hide == 3) return _("Unknown user or password incorrect."); logout_error( _("Unknown user or password incorrect.") ); exit; } |