[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] SF.net SVN: squirrelmail:[14139]
From: pdontthink () users ! sourceforge ! net
Date: 2011-08-05 1:32:56
Message-ID: E1Qp9HU-0001Bp-VL () sfp-svn-5 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 14139
http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=14139&view=rev
Author: pdontthink
Date: 2011-08-05 01:32:56 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Add capability to issue SEARCH commands in literal format (so that non-ASCII search \
terms are handled RFC-correctly). PLEASE HELP TEST, including if you use the Filters \
plugin.
Modified Paths:
--------------
branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog
branches/SM-1_4-STABLE/squirrelmail/functions/imap_general.php
branches/SM-1_4-STABLE/squirrelmail/functions/imap_search.php
branches/SM-1_4-STABLE/squirrelmail/plugins/filters/filters.php
Modified: branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog 2011-07-26 20:28:11 UTC (rev \
14138)
+++ branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog 2011-08-05 01:32:56 UTC (rev \
14139) @@ -4,6 +4,8 @@
Version 1.4.23 - SVN
--------------------
+ - Added capability to issue SEARCH commands in literal format (so that
+ non-ASCII search terms are handled RFC-correctly).
Version 1.4.22 - 12 July 2011
-----------------------------
Modified: branches/SM-1_4-STABLE/squirrelmail/functions/imap_general.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/imap_general.php 2011-07-26 \
20:28:11 UTC (rev 14138)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/imap_general.php 2011-08-05 \
01:32:56 UTC (rev 14139) @@ -79,23 +79,23 @@
function sqimap_run_literal_command($imap_stream, $query, $handle_errors, \
&$response, &$message, $unique_id = false) { if ($imap_stream) {
$sid = sqimap_session_id($unique_id);
- $command = sprintf("%s {%d}\r\n", $query['command'], \
strlen($query['literal_args'][0])); + $command = sprintf("%s {%d}\r\n", \
$query['commands'][0], strlen($query['literal_args'][0])); fputs($imap_stream, $sid \
. ' ' . $command);
// TODO: Put in error handling here //
- $read = sqimap_read_data($imap_stream, $sid, $handle_errors, $response, \
$message, $query['command']); + $read = sqimap_read_data($imap_stream, $sid, \
$handle_errors, $response, $message, $query['commands'][0]);
$i = 0;
$cnt = count($query['literal_args']);
while( $i < $cnt ) {
if (($cnt > 1) && ($i < ($cnt - 1))) {
- $command = sprintf("%s {%d}\r\n", $query['literal_args'][$i], \
strlen($query['literal_args'][$i+1])); + $command = sprintf("%s%s {%d}\r\n", \
$query['literal_args'][$i], (!empty($query['commands'][$i+1]) ? ' ' . \
$query['commands'][$i+1] : ''), strlen($query['literal_args'][$i+1])); } else {
$command = sprintf("%s\r\n", $query['literal_args'][$i]);
}
fputs($imap_stream, $command);
- $read = sqimap_read_data($imap_stream, $sid, $handle_errors, $response, \
$message, $query['command']); + $read = sqimap_read_data($imap_stream, $sid, \
$handle_errors, $response, $message, $query['commands'][0]);
$i++;
@@ -564,8 +564,9 @@
} else {
// Original IMAP login code
if(sq_is8bit($username) || sq_is8bit($password)) {
- $query['command'] = 'LOGIN';
+ $query['commands'][0] = 'LOGIN';
$query['literal_args'][0] = $username;
+ $query['commands'][1] = '';
$query['literal_args'][1] = $password;
$read = sqimap_run_literal_command($imap_stream, $query, false, \
$response, $message); } else {
Modified: branches/SM-1_4-STABLE/squirrelmail/functions/imap_search.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/imap_search.php 2011-07-26 20:28:11 \
UTC (rev 14138)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/imap_search.php 2011-08-05 01:32:56 \
UTC (rev 14139) @@ -44,38 +44,67 @@
}
}
+ $search_literal = array('commands'=>array(), 'literal_args'=>array());
+ $use_search_literal = FALSE;
foreach ($multi_search as $string) {
- $search_string .= $search_where
- . ' "'
- . str_replace(array('\\', '"'), array('\\\\', '\\"'), $string)
- . '" ';
+ //FIXME: why JIS? shouldn't input be in EUC-JP? this is copied from DEVEL
+ if (isset($languages[$squirrelmail_language]['CHARSET']) &&
+ strtoupper($languages[$squirrelmail_language]['CHARSET']) == \
'ISO-2022-JP') + $string = mb_convert_encoding($string, 'JIS', 'auto');
+ if (preg_match('/["\\\\\r\n\x80-\xff]/', $string))
+ $use_search_literal = TRUE;
+ $search_literal['commands'][] = $search_where;
+ $search_literal['literal_args'][] = $string;
+ $search_string .= $search_where
+ . ' "'
+ . str_replace(array('\\', '"'), array('\\\\', '\\"'), \
$string) + . '" ';
}
$search_string = trim($search_string);
+ $original_search_literal = $search_literal;
/* now use $search_string in the imap search */
if ($allow_charset_search && \
isset($languages[$squirrelmail_language]['CHARSET']) && \
$languages[$squirrelmail_language]['CHARSET']) {
- $ss = "SEARCH CHARSET "
- . strtoupper($languages[$squirrelmail_language]['CHARSET'])
- . " ALL $search_string";
+ if ($use_search_literal) {
+ $search_literal['commands'][0] = 'SEARCH CHARSET '
+ . strtoupper($languages[$squirrelmail_language]['CHARSET'])
+ . ' ALL ' . $search_literal['commands'][0];
+ } else {
+ $ss = "SEARCH CHARSET "
+ . strtoupper($languages[$squirrelmail_language]['CHARSET'])
+ . " ALL $search_string";
+ }
} else {
- $ss = "SEARCH ALL $search_string";
+ if ($use_search_literal) {
+ $search_literal['commands'][0] = 'SEARCH ALL ' . \
$search_literal['commands'][0]; + } else {
+ $ss = "SEARCH ALL $search_string";
+ }
}
/* read data back from IMAP */
- $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, \
$uid_support); + if ($use_search_literal) {
+ $readin = sqimap_run_literal_command($imapConnection, $search_literal, \
false, $result, $message, $uid_support); + } else {
+ $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, \
$uid_support); + }
/* try US-ASCII charset if search fails */
if (isset($languages[$squirrelmail_language]['CHARSET'])
&& strtolower($result) == 'no') {
- $ss = "SEARCH CHARSET \"US-ASCII\" ALL $search_string";
- if (empty($search_lit)) {
- $readin = sqimap_run_command($imapConnection, $ss, false, $result, \
$message, $uid_support); + if ($use_search_literal) {
+ $original_search_literal['commands'][0] = 'SEARCH CHARSET "US-ASCII" ALL \
' + . \
$original_search_literal['commands'][0]; } else {
- $search_lit['command'] = $ss;
- $readin = sqimap_run_literal_command($imapConnection, $search_lit, \
false, $result, $message, $uid_support); + $ss = "SEARCH CHARSET \
\"US-ASCII\" ALL $search_string"; }
+ if ($use_search_literal) {
+ $readin = sqimap_run_literal_command($imapConnection, $search_literal, \
false, $result, $message, $uid_support); + } else {
+ $readin = sqimap_run_command($imapConnection, $ss, false, $result, \
$message, $uid_support); + }
}
unset($messagelist);
Modified: branches/SM-1_4-STABLE/squirrelmail/plugins/filters/filters.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/plugins/filters/filters.php 2011-07-26 \
20:28:11 UTC (rev 14138)
+++ branches/SM-1_4-STABLE/squirrelmail/plugins/filters/filters.php 2011-08-05 \
01:32:56 UTC (rev 14139) @@ -335,7 +335,7 @@
$read = sqimap_run_command_list($imap, $search_str, true, $response, \
$message, $uid_support); } else {
$lit = array();
- $lit['command'] = $search_str . ' ' . $where;
+ $lit['commands'][] = $search_str . ' ' . $where;
$lit['literal_args'][] = $what;
$read = sqimap_run_literal_command($imap, $lit, true, $response, $message, \
$uid_support );
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
-----
squirrelmail-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic