aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-08-31 06:25:15 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-08-31 06:25:15 +0800
commit6c1e363f9caa60ca7077f722443ff455a9fa8f7e (patch)
tree676ae2660708f9229d1681cfa475e2f9e2330a03
parent61ec555e80b3e208c09a81bb2f2df530d947d360 (diff)
downloadgsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.tar
gsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.tar.gz
gsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.tar.bz2
gsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.tar.lz
gsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.tar.xz
gsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.tar.zst
gsoc2013-evolution-6c1e363f9caa60ca7077f722443ff455a9fa8f7e.zip
Rewrote to ignore strings that look like server responses until it is sure
2000-08-30 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c (camel_imap_fetch_command): Rewrote to ignore strings that look like server responses until it is sure that it has finished reading the literal string response. svn path=/trunk/; revision=5124
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/providers/imap/camel-imap-store.c56
-rw-r--r--camel/providers/imap/camel-imap-stream.c19
3 files changed, 69 insertions, 12 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index b72bd0cf62..012f305998 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,11 @@
2000-08-30 Jeffrey Stedfast <fejj@helixcode.com>
+ * providers/imap/camel-imap-store.c (camel_imap_fetch_command):
+ Rewrote to ignore strings that look like server responses until it
+ is sure that it has finished reading the literal string response.
+
+2000-08-30 Jeffrey Stedfast <fejj@helixcode.com>
+
* camel-remote-store.c (remote_send_string): Don't wrap printed
strings in quotes, makes things messy
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 98cfd9095f..4be5300e70 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -680,6 +680,7 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
va_list ap;
gint i;
+ /* check for current folder */
status = check_current_folder (store, folder, fmt, ex);
if (status != CAMEL_IMAP_OK)
return status;
@@ -831,11 +832,13 @@ camel_imap_fetch_command (CamelImapStore *store, CamelFolder *folder, char **ret
* possibly contain strings that appear to be valid server
* responses but aren't. We should, therefor, find a way to
* determine whether we are actually reading server responses.
- */
+ */
gint status = CAMEL_IMAP_OK;
GPtrArray *data, *expunged;
+ gboolean is_notification;
gchar *respbuf, *cmdid;
guint32 len = 0;
+ gint partlen = 0;
gint recent = 0;
va_list ap;
gint i;
@@ -853,6 +856,46 @@ camel_imap_fetch_command (CamelImapStore *store, CamelFolder *folder, char **ret
va_end (ap);
data = g_ptr_array_new ();
+
+ /* get first response line */
+ if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &respbuf, ex) != -1) {
+ char *p, *q;
+
+ g_ptr_array_add (data, respbuf);
+ len += strlen (respbuf) + 1;
+
+ for (p = respbuf; *p && *p != '{' && *p != '"' && *p != '\n'; p++);
+ switch (*p) {
+ case '"':
+ /* a quoted string - section 4.3 */
+ p++;
+ for (q = p; *q && *q != '"'; q++);
+ partlen = (guint32) (q - p);
+
+ is_notification = TRUE;
+
+ break;
+ case '{':
+ /* a literal string - section 4.3 */
+ partlen = atoi (p + 1);
+
+ /* add len to partlen because the partlen
+ doesn't count the first response buffer */
+ partlen += len;
+
+ is_notification = FALSE;
+
+ break;
+ default:
+ /* bad input */
+ g_ptr_array_free (data, TRUE);
+ return CAMEL_IMAP_FAIL;
+ }
+ } else {
+ g_ptr_array_free (data, TRUE);
+ return CAMEL_IMAP_FAIL;
+ }
+
expunged = g_ptr_array_new ();
/* read multi-line response */
@@ -874,11 +917,12 @@ camel_imap_fetch_command (CamelImapStore *store, CamelFolder *folder, char **ret
len += strlen (respbuf) + 1;
/* IMAPs multi-line response ends with the cmdid string at the beginning of the line */
- if (!strncmp (respbuf, cmdid, strlen (cmdid))) {
+ if (is_notification && !strncmp (respbuf, cmdid, strlen (cmdid))) {
status = camel_imap_status (cmdid, respbuf);
break;
}
+ /* FIXME: this is redundant */
/* If recent or expunge flags were somehow set and this
response doesn't begin with a '*' then
recent/expunged must have been misdetected */
@@ -894,7 +938,7 @@ camel_imap_fetch_command (CamelImapStore *store, CamelFolder *folder, char **ret
}
/* Check for a RECENT in the untagged response */
- if (*respbuf == '*') {
+ if (*respbuf == '*' && is_notification) {
if (strstr (respbuf, "RECENT")) {
char *rcnt;
@@ -916,6 +960,12 @@ camel_imap_fetch_command (CamelImapStore *store, CamelFolder *folder, char **ret
}
}
}
+
+ if (!is_notification) {
+ partlen--;
+ if (len >= partlen)
+ is_notification = TRUE;
+ }
}
if (status == CAMEL_IMAP_OK) {
diff --git a/camel/providers/imap/camel-imap-stream.c b/camel/providers/imap/camel-imap-stream.c
index a59be149d9..8c04b75ec9 100644
--- a/camel/providers/imap/camel-imap-stream.c
+++ b/camel/providers/imap/camel-imap-stream.c
@@ -45,7 +45,7 @@ camel_imap_stream_class_init (CamelImapStreamClass *camel_imap_stream_class)
CamelStreamClass *camel_stream_class =
CAMEL_STREAM_CLASS (camel_imap_stream_class);
- parent_class = CAMEL_STREAM_CLASS(camel_type_get_global_classfuncs (camel_stream_get_type ()));
+ parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
/* virtual method overload */
camel_stream_class->read = stream_read;
@@ -68,13 +68,14 @@ camel_imap_stream_get_type (void)
static CamelType camel_imap_stream_type = CAMEL_INVALID_TYPE;
if (camel_imap_stream_type == CAMEL_INVALID_TYPE) {
- camel_imap_stream_type = camel_type_register (camel_stream_get_type (), "CamelImapStream",
- sizeof (CamelImapStream),
- sizeof (CamelImapStreamClass),
- (CamelObjectClassInitFunc) camel_imap_stream_class_init,
- NULL,
- (CamelObjectInitFunc) camel_imap_stream_init,
- (CamelObjectFinalizeFunc) finalize);
+ camel_imap_stream_type =
+ camel_type_register (camel_stream_get_type (), "CamelImapStream",
+ sizeof (CamelImapStream),
+ sizeof (CamelImapStreamClass),
+ (CamelObjectClassInitFunc) camel_imap_stream_class_init,
+ NULL,
+ (CamelObjectInitFunc) camel_imap_stream_init,
+ (CamelObjectFinalizeFunc) finalize);
}
return camel_imap_stream_type;
@@ -129,7 +130,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n)
imap_stream->command);
/* FIXME: exception is ignored */
camel_exception_clear (&ex);
-
+
if (!result || status != CAMEL_IMAP_OK) {
/* we got an error, dump this stuff */
g_free (result);