From 56afb33f40bc96f5bf950f2af98f2db11a249e67 Mon Sep 17 00:00:00 2001 From: stekkel Date: Mon, 26 Aug 2002 09:27:43 +0000 Subject: [PATCH 1/1] quick hack to remove the preg_match for * [0-9]+ FETCH in case of sqimap_run_command. Explanation: if we request for a single fetch (not a list) we shouldn't look for extra fetch lines because this stops the processing in case of body entities with * a001 fetch lines. Later we can glue the 2 functions together if we add information to sqimap_read_data_list about the nature of the call (list or not) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3458 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 73 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index 11586a18..4cc79942 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -87,10 +87,11 @@ function sqimap_read_data_list ($imap_stream, $pre, $handle_errors, &$response, case preg_match("/^\* (OK \[PARSE\])(.*)$/", $read): $read = sqimap_fgets($imap_stream); break 1; - case preg_match('/^\* [0-9]+ FETCH.*/', $read): + case preg_match('/^\* ([0-9]+) FETCH.*/', $read, $regs): $fetch_data = array(); $fetch_data[] = $read; $read = sqimap_fgets($imap_stream); + $i = 0; while (!preg_match('/^\* [0-9]+ FETCH.*/', $read) && !preg_match("/^$pre (OK|BAD|NO)(.*)$/", $read)) { $fetch_data[] = $read; @@ -144,8 +145,74 @@ function sqimap_read_data_list ($imap_stream, $pre, $handle_errors, &$response, } function sqimap_read_data ($imap_stream, $pre, $handle_errors, &$response, &$message, $query = '') { - $res = sqimap_read_data_list($imap_stream, $pre, $handle_errors, $response, $message, $query); - return $res[0]; + global $color, $squirrelmail_language; + $read = ''; + $pre_a = explode(' ',trim($pre)); + $pre = $pre_a[0]; + $result = ''; + $data = array(); + $read = sqimap_fgets($imap_stream); + while (1) { + switch (true) { + case preg_match("/^$pre (OK|BAD|NO)(.*)$/", $read, $regs): + case preg_match('/^\* (BYE \[ALERT\])(.*)$/', $read, $regs): + $response = $regs[1]; + $message = trim($regs[2]); + break 2; + case preg_match("/^\* (OK \[PARSE\])(.*)$/", $read): + $read = sqimap_fgets($imap_stream); + break 1; + case preg_match('/^\* [0-9]+ FETCH.*/', $read): + $fetch_data = array(); + $fetch_data[] = $read; + $read = sqimap_fgets($imap_stream); + while (!preg_match("/^$pre (OK|BAD|NO)(.*)$/", $read)) { + $fetch_data[] = $read; + $read = sqimap_fgets($imap_stream); + } + $result = $fetch_data; + break 2; + default: + $data[] = $read; + $read = sqimap_fgets($imap_stream); + break 1; + } + } + if (!empty($data)) { + $result = $data; + } + if ($handle_errors == false) { + return( $result ); + } + elseif ($response == 'NO') { + /* ignore this error from M$ exchange, it is not fatal (aka bug) */ + if (strstr($message, 'command resulted in') === false) { + set_up_language($squirrelmail_language); + echo "
\n" . + _("ERROR : Could not complete request.") . + "
\n" . + _("Query:") . + $query . '
' . + _("Reason Given: ") . + $message . "

\n"; + exit; + } + } + elseif ($response == 'BAD') { + set_up_language($squirrelmail_language); + echo "
\n" . + _("ERROR : Bad or malformed request.") . + "
\n" . + _("Query:") . + $query . '
' . + _("Server responded: ") . + $message . "

\n"; + exit; + } + else { + return $result; + } + } /* -- 2.25.1