X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fimap_general.php;h=3b355f9e2c2dd5226fff9cd4fd3580f843890fce;hp=6011497ebb5f151bd77b3276f29709b365138d70;hb=HEAD;hpb=935d09e135efa05b02313fea08794139c8963ec7
diff --git a/functions/imap_general.php b/functions/imap_general.php
index 6011497e..3b355f9e 100755
--- a/functions/imap_general.php
+++ b/functions/imap_general.php
@@ -5,7 +5,7 @@
*
* This implements all functions that do general IMAP functions.
*
- * @copyright © 1999-2007 The SquirrelMail Project Team
+ * @copyright 1999-2022 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
@@ -60,11 +60,14 @@ function sqimap_run_command_list ($imap_stream, $query, $handle_errors, &$respon
$message = $message[$tag];
$response = $response[$tag];
return $read[$tag];
+//FIXME: obey $handle_errors below!
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
+//FIXME: NO HTML IN CORE!
$string = "\n" .
_("ERROR: No available IMAP stream.") .
+//FIXME: NO HTML IN CORE!
"\n";
error_box($string);
return false;
@@ -106,15 +109,33 @@ function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response,
$message = $message[$tag];
if (!empty($read[$tag])) {
+ /* sqimap_read_data should be called for one response
+ but since it just calls sqimap_retrieve_imap_response
+ which handles multiple responses we need to check for
+ that and merge the $read[$tag] array IF they are
+ separated and IF it was a FETCH response. */
+
+ if (isset($read[$tag][1]) && is_array($read[$tag][1]) && isset($read[$tag][1][0])
+ && preg_match('/^\* \d+ FETCH/', $read[$tag][1][0])) {
+ $result = array();
+ foreach($read[$tag] as $index => $value) {
+ $result = array_merge($result, $read[$tag]["$index"]);
+ }
+ return $result;
+ }
+
return $read[$tag][0];
} else {
return $read[$tag];
}
+//FIXME: obey $handle_errors below!
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
+//FIXME: NO HTML IN CORE!
$string = "\n" .
_("ERROR: No available IMAP stream.") .
+//FIXME: NO HTML IN CORE!
"\n";
error_box($string);
return false;
@@ -316,8 +337,10 @@ function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
&$response, &$message, $query = '') {
global $color, $oTemplate, $squirrelmail_language;
set_up_language($squirrelmail_language);
+//FIXME: NO HTML IN CORE!
$string = "\n" .
_("ERROR: Bad function call.") .
+//FIXME: NO HTML IN CORE!
"
\n" .
_("Reason:") . ' '.
'There is a plugin installed which make use of the
' .
@@ -325,7 +348,8 @@ function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
'Please adapt the installed plugin and let it use
'.
'sqimap_run_command or sqimap_run_command_list instead
'.
'The following query was issued:
'.
- htmlspecialchars($query) . '
' . "
\n";
+//FIXME: NO HTML IN CORE!
+ sm_encode_html_special_chars($query) . '
' . "
\n";
error_box($string);
$oTemplate->display('footer.tpl');
exit;
@@ -346,16 +370,18 @@ function sqimap_error_box($title, $query = '', $message_title = '', $message = '
global $color, $squirrelmail_language;
set_up_language($squirrelmail_language);
+//FIXME: NO HTML IN CORE!
$string = "\n" . $title . "
\n";
$cmd = explode(' ',$query);
$cmd= strtolower($cmd[0]);
if ($query != '' && $cmd != 'login')
- $string .= _("Query:") . ' ' . htmlspecialchars($query) . '
';
+ $string .= _("Query:") . ' ' . sm_encode_html_special_chars($query) . '
';
if ($message_title != '')
$string .= $message_title;
if ($message != '')
- $string .= htmlspecialchars($message);
+ $string .= sm_encode_html_special_chars($message);
+//FIXME: NO HTML IN CORE!
$string .= "
\n";
if ($link != '')
$string .= $link;
@@ -384,7 +410,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
$read = '';
if (!is_array($message)) $message = array();
if (!is_array($response)) $response = array();
- $aResponse = '';
+ $aResponse = array();
$resultlist = array();
$data = array();
$sCommand = '';
@@ -396,7 +422,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
$read = sqimap_fgets($imap_stream);
$i = 0;
while ($read) {
- $char = $read{0};
+ $char = $read[0];
switch ($char)
{
case '+':
@@ -404,7 +430,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
$read = sqimap_fgets($imap_stream);
break;
- case $tag{0}:
+ case $tag[0]:
{
/* get the command */
$arg = '';
@@ -452,7 +478,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
break 2; /* switch while */
}
break;
- } // end case $tag{0}
+ } // end case $tag[0]
case '*':
{
@@ -504,11 +530,11 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
break 4; /* while while switch while */
}
/* check for next untagged reponse and break */
- if ($read{0} == '*') break 2;
+ if ($read[0] == '*') break 2;
$s = substr($read,-3);
} while ($s === "}\r\n" || $read_literal);
$s = substr($read,-3);
- } while ($read{0} !== '*' &&
+ } while ($read[0] !== '*' &&
substr($read,0,strlen($tag)) !== $tag);
$resultlist[] = $fetch_data;
/* release not neaded data */
@@ -540,7 +566,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
$read = sqimap_fgets($imap_stream);
if ($read === false) {
break 3; /* while switch while */
- } else if ($read{0} == '*') {
+ } else if ($read[0] == '*') {
break;
}
$s = substr($read,-3);
@@ -561,6 +587,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
$query = '';
}
sqimap_error_box(_("ERROR: IMAP server closed the connection."), $query, _("Server responded:"),$sResponse);
+//FIXME: NO HTML IN CORE!
echo '