// starttls was successful
/**
- * RFC 2595 requires to discard CAPABILITY information after successful
- * STARTTLS command. We don't follow RFC, because SquirrelMail stores CAPABILITY
- * information only after successful login (src/redirect.php) and cached information
- * is used only in other php script connections after successful STARTTLS. If script
- * issues sqimap_capability() call before sqimap_login() and wants to get initial
- * capability response, script should set third sqimap_capability() argument to false.
+ * RFC 2595 requires to discard CAPABILITY information after successful
+ * STARTTLS command. We don't follow RFC, because SquirrelMail stores CAPABILITY
+ * information only after successful login (src/redirect.php) and cached information
+ * is used only in other php script connections after successful STARTTLS. If script
+ * issues sqimap_capability() call before sqimap_login() and wants to get initial
+ * capability response, script should set third sqimap_capability() argument to false.
*/
- //sqsession_unregister('sqimap_capabilities');
+ //sqsession_unregister('sqimap_capabilities');
} else {
/**
* stream_socket_enable_crypto() call failed. Possible issues:
* - broken ssl certificate (uw drops connection, error is in syslog mail facility)
- * - some ssl error (can reproduce with STREAM_CRYPTO_METHOD_SSLv3_CLIENT, PHP E_WARNING
+ * - some ssl error (can reproduce with STREAM_CRYPTO_METHOD_SSLv3_CLIENT, PHP E_WARNING
* suppressed in stream_socket_enable_crypto() call)
*/
sqimap_error_box(sprintf(_("Error connecting to IMAP server: %s."), $server),
'','',
_("Unable to start TLS."));
/**
- * Bug: stream_socket_enable_crypto() does not register SSL errors in
- * openssl_error_string() or stream notification wrapper and displays
- * them in E_WARNING level message. It is impossible to retrieve error
+ * Bug: stream_socket_enable_crypto() does not register SSL errors in
+ * openssl_error_string() or stream notification wrapper and displays
+ * them in E_WARNING level message. It is impossible to retrieve error
* message without own error handler.
*/
exit;
* else returns array of all capabilities.
* @param stream $imap_stream
* @param string $capability (since 1.3.0)
- * @param boolean $bUseCache (since 1.5.1) Controls use of capability data stored in session
+ * @param boolean $bUseCache (since 1.5.1) Controls use of capability data stored in session
* @return mixed (string if $capability is set and found,
* false, if $capability is set and not found,
* array if $capability not set)
* @since 1.5.1 and 1.4.5
*/
function sqimap_append_checkresponse($response, $folder) {
-
+ // TODO use error handler, see how sort and thread errors are handled and see errors.php
if (preg_match("/(.*)(BAD|NO)(.*)$/", $response, $regs)) {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
// use sqimap_run_command_list in case of unsollicited responses. If we don't we could loose the SORT response
$aData = sqimap_run_command_list ($imap_stream, $query, false, $response, $message, TRUE);
/* fallback to default charset */
- if ($response == 'NO' && strpos($message,'[BADCHARSET]') !== false) {
- $query = "SORT ($sSortField) US-ASCII $search";
- $aData = sqimap_run_command_list ($imap_stream, $query, true, $response, $message, TRUE);
+ if ($response == 'NO') {
+ if (strpos($message,'[BADCHARSET]') !== false ||
+ strpos($message,'Unrecognized character set') !== false) {
+ sqm_trigger_imap_error('SQM_IMAP_BADCHARSET',$query, $response, $message);
+ $query = "SORT ($sSortField) US-ASCII $search";
+ $aData = sqimap_run_command_list ($imap_stream, $query, true, $response, $message, TRUE);
+ } else {
+ sqm_trigger_imap_error('SQM_IMAP_ERROR',$query, $response, $message);
+ }
+ } else if ($response == 'BAD') {
+ sqm_trigger_imap_error('SQM_IMAP_NO_SORT',$query, $response, $message);
}
}
-
if ($response == 'OK') {
return parseUidList($aData,'SORT');
} else {
}
$query = "THREAD $sort_type ".strtoupper($default_charset)." $search";
+ // TODO use sqimap_run_command_list as we do in get_server_sort()
$thread_test = sqimap_run_command ($imap_stream, $query, false, $response, $message, TRUE);
/* fallback to default charset */
- if ($response == 'NO' && strpos($message,'[BADCHARSET]') !== false) {
- $query = "THREAD $sort_type US-ASCII $search";
- $thread_test = sqimap_run_command ($imap_stream, $query, true, $response, $message, TRUE);
+
+ if ($response == 'NO') {
+ if (strpos($message,'[BADCHARSET]') !== false ||
+ strpos($message,'Unrecognized character set') !== false) {
+ sqm_trigger_imap_error('SQM_IMAP_BADCHARSET',$query, $response, $message);
+ $query = "THREAD $sort_type US-ASCII $search";
+ $thread_test = sqimap_run_command ($imap_stream, $query, true, $response, $message, TRUE);
+ } else {
+ sqm_trigger_imap_error('SQM_IMAP_ERROR',$query, $response, $message);
+ }
+ } elseif ($response == 'BAD') {
+ sqm_trigger_imap_error('SQM_IMAP_NO_THREAD',$query, $response, $message);
}
if (isset($thread_test[0])) {
for ($i=0,$iCnt=count($thread_test);$i<$iCnt;++$i) {
$thread_list = "";
}
if (!preg_match("/OK/", $response)) {
- $server_sort_array = 'no';
+ $server_sort_array = false;
return $server_sort_array;
}
if (isset($thread_list)) {