diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-08-10 06:48:12 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-08-10 06:48:12 +0800 |
commit | a1dbf7e2b8b79455eedec53cc9f2221e97215a9f (patch) | |
tree | b0bf3f378203d7896c2995cabb158814aebbb9cd | |
parent | 80f09e4507d10a14a009c882bb0df5ec6e795de7 (diff) | |
download | gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.tar gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.tar.gz gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.tar.bz2 gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.tar.lz gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.tar.xz gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.tar.zst gsoc2013-evolution-a1dbf7e2b8b79455eedec53cc9f2221e97215a9f.zip |
A quoted string cannot contain \n's so check for those as well.
2001-08-09 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap/camel-imap-utils.c (imap_parse_string_generic): A
quoted string cannot contain \n's so check for those as well.
(imap_atom_specials): Update this to fix bug #6553.
svn path=/trunk/; revision=11845
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-filter-driver.c | 6 | ||||
-rw-r--r-- | camel/camel-sasl.c | 22 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-command.c | 128 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 56 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-utils.c | 145 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 48 |
7 files changed, 207 insertions, 204 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index dd3e285e82..865c8ddd9e 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2001-08-09 Jeffrey Stedfast <fejj@ximian.com> + + * providers/imap/camel-imap-utils.c (imap_parse_string_generic): A + quoted string cannot contain \n's so check for those as well. + (imap_atom_specials): Update this to fix bug #6553. + 2001-08-08 Jon Trowbridge <trow@ximian.com> * camel-filter-search.c (get_source): Remove trailing stuff from diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index affc77b858..181cbed9a9 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -582,9 +582,9 @@ camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, co const CamelInternetAddress *from; char date[50]; time_t t; - + /* FIXME: does this need locking? Probably */ - + from = camel_mime_message_get_from (p->message); fromstr = camel_address_format((CamelAddress *)from); subject = camel_mime_message_get_subject (p->message); @@ -638,7 +638,7 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox, co int status; CamelMessageInfo *info; off_t last = 0; - + fd = open (mbox, O_RDONLY); if (fd == -1) { camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to open spool folder")); diff --git a/camel/camel-sasl.c b/camel/camel-sasl.c index 7f58a84bb7..c70a52d8a8 100644 --- a/camel/camel-sasl.c +++ b/camel/camel-sasl.c @@ -104,7 +104,7 @@ GByteArray * camel_sasl_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex) { g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL); - + return CS_CLASS (sasl)->challenge (sasl, token, ex); } @@ -125,9 +125,9 @@ camel_sasl_challenge_base64 (CamelSasl *sasl, const char *token, CamelException GByteArray *token_binary, *ret_binary; char *ret; int len; - + g_return_val_if_fail (CAMEL_IS_SASL (sasl), NULL); - + if (token) { token_binary = g_byte_array_new (); len = strlen (token); @@ -135,13 +135,13 @@ camel_sasl_challenge_base64 (CamelSasl *sasl, const char *token, CamelException token_binary->len = base64_decode_simple (token_binary->data, len); } else token_binary = NULL; - + ret_binary = camel_sasl_challenge (sasl, token_binary, ex); if (token_binary) g_byte_array_free (token_binary, TRUE); if (!ret_binary) return NULL; - + ret = base64_encode_simple (ret_binary->data, ret_binary->len); g_byte_array_free (ret_binary, TRUE); @@ -178,13 +178,13 @@ CamelSasl * camel_sasl_new (const char *service_name, const char *mechanism, CamelService *service) { CamelSasl *sasl; - + g_return_val_if_fail (service_name != NULL, NULL); g_return_val_if_fail (mechanism != NULL, NULL); g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL); - + /* We don't do ANONYMOUS here, because it's a little bit weird. */ - + if (!strcmp (mechanism, "CRAM-MD5")) sasl = (CamelSasl *)camel_object_new (CAMEL_SASL_CRAM_MD5_TYPE); else if (!strcmp (mechanism, "DIGEST-MD5")) @@ -201,11 +201,11 @@ camel_sasl_new (const char *service_name, const char *mechanism, CamelService *s sasl = (CamelSasl *)camel_object_new (CAMEL_SASL_POPB4SMTP_TYPE); else return NULL; - + sasl->service_name = g_strdup (service_name); sasl->service = service; camel_object_ref (CAMEL_OBJECT (service)); - + return sasl; } @@ -220,7 +220,7 @@ GList * camel_sasl_authtype_list (gboolean include_plain) { GList *types = NULL; - + types = g_list_prepend (types, &camel_sasl_cram_md5_authtype); types = g_list_prepend (types, &camel_sasl_digest_md5_authtype); #ifdef HAVE_KRB4 diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c index 4c84b47fbb..b5b80624ef 100644 --- a/camel/providers/imap/camel-imap-command.c +++ b/camel/providers/imap/camel-imap-command.c @@ -84,9 +84,9 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, { va_list ap; char *cmd; - + CAMEL_IMAP_STORE_LOCK (store, command_lock); - + if (fmt) { va_start (ap, fmt); cmd = imap_command_strdup_vprintf (store, fmt, ap); @@ -101,14 +101,14 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder, cmd = imap_command_strdup_printf (store, "SELECT %F", folder->full_name); } - + if (!imap_command_start (store, folder, cmd, ex)) { g_free (cmd); CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return NULL; } g_free (cmd); - + return imap_read_response (store, ex); } @@ -152,15 +152,15 @@ camel_imap_command_start (CamelImapStore *store, CamelFolder *folder, va_list ap; char *cmd; gboolean ok; - + va_start (ap, fmt); cmd = imap_command_strdup_vprintf (store, fmt, ap); va_end (ap); - + CAMEL_IMAP_STORE_LOCK (store, command_lock); ok = imap_command_start (store, folder, cmd, ex); g_free (cmd); - + if (!ok) CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return ok; @@ -174,7 +174,7 @@ imap_command_start (CamelImapStore *store, CamelFolder *folder, if (folder && folder != store->current_folder) { CamelImapResponse *response; CamelException internal_ex; - + response = camel_imap_command (store, folder, ex, NULL); if (!response) return NULL; @@ -186,7 +186,7 @@ imap_command_start (CamelImapStore *store, CamelFolder *folder, return FALSE; } } - + /* Send the command */ return camel_remote_store_send_string (CAMEL_REMOTE_STORE (store), ex, "%c%.5d %s\r\n", @@ -218,7 +218,7 @@ camel_imap_command_continuation (CamelImapStore *store, const char *cmd, CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return NULL; } - + return imap_read_response (store, ex); } @@ -243,17 +243,17 @@ camel_imap_command_response (CamelImapStore *store, char **response, { CamelImapResponseType type; char *respbuf; - + if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &respbuf, ex) < 0) { CAMEL_IMAP_STORE_UNLOCK (store, command_lock); return CAMEL_IMAP_RESPONSE_ERROR; } - + switch (*respbuf) { case '*': type = CAMEL_IMAP_RESPONSE_UNTAGGED; - + /* Read the rest of the response if it is multi-line. */ respbuf = imap_read_untagged (store, respbuf, ex); if (!respbuf) @@ -273,7 +273,7 @@ camel_imap_command_response (CamelImapStore *store, char **response, break; } *response = respbuf; - + if (type == CAMEL_IMAP_RESPONSE_ERROR || type == CAMEL_IMAP_RESPONSE_TAGGED) CAMEL_IMAP_STORE_UNLOCK (store, command_lock); @@ -286,39 +286,39 @@ imap_read_response (CamelImapStore *store, CamelException *ex) CamelImapResponse *response; CamelImapResponseType type; char *respbuf, *p; - + /* Get another lock so that when we reach the tagged * response and camel_imap_command_response unlocks, * we're still locked. This lock is owned by response * and gets unlocked when response is freed. */ CAMEL_IMAP_STORE_LOCK (store, command_lock); - + response = g_new0 (CamelImapResponse, 1); if (store->current_folder && camel_disco_store_status (CAMEL_DISCO_STORE (store)) != CAMEL_DISCO_STORE_RESYNCING) { response->folder = store->current_folder; camel_object_ref (CAMEL_OBJECT (response->folder)); } - + response->untagged = g_ptr_array_new (); while ((type = camel_imap_command_response (store, &respbuf, ex)) == CAMEL_IMAP_RESPONSE_UNTAGGED) g_ptr_array_add (response->untagged, respbuf); - + if (type == CAMEL_IMAP_RESPONSE_ERROR) { camel_imap_response_free_without_processing (store, response); return NULL; } - + response->status = respbuf; - + /* Check for OK or continuation response. */ if (*respbuf == '+') return response; p = strchr (respbuf, ' '); if (p && !g_strncasecmp (p, " OK", 3)) return response; - + /* We should never get BAD, or anything else but +, OK, or NO * for that matter. */ @@ -331,7 +331,7 @@ imap_read_response (CamelImapStore *store, CamelException *ex) camel_imap_response_free_without_processing (store, response); return NULL; } - + p += 3; if (!*p++) p = NULL; @@ -353,29 +353,29 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) GPtrArray *data; GString *str; char *end, *p, *s, *d; - + p = strrchr (line, '{'); if (!p) return line; - + data = g_ptr_array_new (); fulllen = 0; - + while (1) { str = g_string_new (line); g_free (line); fulllen += str->len; g_ptr_array_add (data, str); - + p = strrchr (str->str, '{'); if (!p) break; - + length = strtoul (p + 1, &end, 10); if (*end != '}' || *(end + 1) || end == p + 1) break; ldigits = end - (p + 1); - + /* Read the literal */ str = g_string_sized_new (length + 2); str->str[0] = '\n'; @@ -397,7 +397,7 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) goto lose; } str->str[length + 1] = '\0'; - + /* Fix up the literal, turning CRLFs into LF. Also, if * we find any embedded NULs, strip them. This is * dubious, but: @@ -411,7 +411,7 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) * inserts a NUL into the last line when it * shouldn't. */ - + s = d = str->str + 1; end = str->str + 1 + length; while (s < end) { @@ -427,7 +427,7 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) } *d = '\0'; str->len = length + 1; - + /* p points to the "{" in the line that starts the * literal. The length of the CR-less response must be * less than or equal to the length of the response @@ -437,16 +437,16 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) * GString's length would be off... */ sprintf (p, "{%0*d}", ldigits, length); - + fulllen += str->len; g_ptr_array_add (data, str); - + /* Read the next line. */ if (camel_remote_store_recv_line (CAMEL_REMOTE_STORE (store), &line, ex) < 0) goto lose; } - + /* Now reassemble the data. */ p = line = g_malloc (fulllen + 1); for (i = 0; i < data->len; i++) { @@ -458,7 +458,7 @@ imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex) *p = '\0'; g_ptr_array_free (data, TRUE); return line; - + lose: for (i = 0; i < data->len; i++) g_string_free (data->pdata[i], TRUE); @@ -481,13 +481,13 @@ camel_imap_response_free (CamelImapStore *store, CamelImapResponse *response) int i, number, exists = 0; GArray *expunged = NULL; char *resp, *p; - + if (!response) return; - + for (i = 0; i < response->untagged->len; i++) { resp = response->untagged->pdata[i]; - + if (response->folder) { /* Check if it's something we need to handle. */ number = strtoul (resp + 2, &p, 10); @@ -503,10 +503,10 @@ camel_imap_response_free (CamelImapStore *store, CamelImapResponse *response) } g_free (resp); } - + g_ptr_array_free (response->untagged, TRUE); g_free (response->status); - + if (response->folder) { if (exists > 0 || expunged) { /* Update the summary */ @@ -515,10 +515,10 @@ camel_imap_response_free (CamelImapStore *store, CamelImapResponse *response) if (expunged) g_array_free (expunged, TRUE); } - + camel_object_unref (CAMEL_OBJECT (response->folder)); } - + g_free (response); CAMEL_IMAP_STORE_UNLOCK (store, command_lock); } @@ -565,18 +565,18 @@ camel_imap_response_extract (CamelImapStore *store, { int len = strlen (type), i; char *resp; - + for (i = 0; i < response->untagged->len; i++) { resp = response->untagged->pdata[i]; /* Skip "* ", and initial sequence number, if present */ strtoul (resp + 2, &resp, 10); if (*resp == ' ') resp = imap_next_word (resp); - + if (!g_strncasecmp (resp, type, len)) break; } - + if (i < response->untagged->len) { resp = response->untagged->pdata[i]; g_ptr_array_remove_index (response->untagged, i); @@ -586,7 +586,7 @@ camel_imap_response_extract (CamelImapStore *store, _("IMAP server response did not contain " "%s information"), type); } - + camel_imap_response_free (store, response); return resp; } @@ -610,14 +610,14 @@ camel_imap_response_extract_continuation (CamelImapStore *store, CamelException *ex) { char *status; - + if (response->status && *response->status == '+') { status = response->status; response->status = NULL; camel_imap_response_free (store, response); return status; } - + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, _("Unexpected OK response from IMAP server: %s"), response->status); @@ -633,9 +633,9 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, const char *p, *start; char *out, *op, *string; int num, len, i, arglen; - + args = g_ptr_array_new (); - + /* Determine the length of the data */ len = strlen (fmt); p = start = fmt; @@ -643,7 +643,7 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, p = strchr (start, '%'); if (!p) break; - + switch (*++p) { case 'd': num = va_arg (ap, int); @@ -651,14 +651,14 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, start = p + 1; len += 10; break; - + case 's': string = va_arg (ap, char *); g_ptr_array_add (args, string); start = p + 1; len += strlen (string); break; - + case 'S': case 'F': string = va_arg (ap, char *); @@ -672,11 +672,11 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, len += arglen * 2; start = p + 1; break; - + case '%': start = p; break; - + default: g_warning ("camel-imap-command is not printf. I don't " "know what '%%%c' means.", *p); @@ -684,7 +684,7 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, break; } } - + /* Now write out the string */ op = out = g_malloc (len + 1); p = start = fmt; @@ -698,18 +698,18 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, strncpy (op, start, p - start); op += p - start; } - + switch (*++p) { case 'd': num = GPOINTER_TO_INT (args->pdata[i++]); op += sprintf (op, "%d", num); break; - + case 's': string = args->pdata[i++]; op += sprintf (op, "%s", string); break; - + case 'S': case 'F': string = args->pdata[i++]; @@ -726,15 +726,15 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt, if (*p == 'F') g_free (string); break; - + default: *op++ = '%'; *op++ = *p; } - + start = *p ? p + 1 : p; } - + return out; } @@ -743,10 +743,10 @@ imap_command_strdup_printf (CamelImapStore *store, const char *fmt, ...) { va_list ap; char *result; - + va_start (ap, fmt); result = imap_command_strdup_vprintf (store, fmt, ap); va_end (ap); - + return result; } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index b1baaf718f..9eff81ecf3 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -617,7 +617,7 @@ imap_connect_online (CamelService *service, CamelException *ex) } if (!store->namespace) store->namespace = g_strdup (""); - + if (!store->dir_sep) { if (store->server_level >= IMAP_LEVEL_IMAP4REV1) { /* This idiom means "tell me the hierarchy separator @@ -637,7 +637,7 @@ imap_connect_online (CamelService *service, CamelException *ex) } if (!response) goto done; - + result = camel_imap_response_extract (store, response, "LIST", NULL); if (result) { imap_parse_list_response (store, result, NULL, &store->dir_sep, NULL); @@ -646,7 +646,7 @@ imap_connect_online (CamelService *service, CamelException *ex) if (!store->dir_sep) store->dir_sep = '/'; /* Guess */ } - + /* Write namespace/separator out */ camel_file_util_encode_string (storeinfo, store->namespace); camel_file_util_encode_uint32 (storeinfo, store->dir_sep); @@ -983,20 +983,20 @@ create_folder (CamelStore *store, const char *parent_name, char *full_name, *resp, *thisone; gboolean need_convert; int i, flags; - + if (!camel_disco_store_check_online (CAMEL_DISCO_STORE (store), ex)) return NULL; if (!parent_name) parent_name = ""; - + /* check if the parent allows inferiors */ - + need_convert = FALSE; response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %F", parent_name); if (!response) /* whoa, this is bad */ return NULL; - + /* FIXME: does not handle unexpected circumstances very well */ for (i = 0; i < response->untagged->len; i++) { resp = response->untagged->pdata[i]; @@ -1012,18 +1012,18 @@ create_folder (CamelStore *store, const char *parent_name, } camel_imap_response_free (imap_store, response); - + /* if not, check if we can delete it and recreate it */ if (need_convert) { gchar *name; CamelException internal_ex; - + if (get_folder_status (imap_store, parent_name, "MESSAGES")) { camel_exception_set (ex, CAMEL_EXCEPTION_FOLDER_INVALID_STATE, _("The parent folder is not allowed to contain subfolders")); return NULL; } - + /* delete the old parent and recreate it */ camel_exception_init (&internal_ex); delete_folder (store, parent_name, &internal_ex); @@ -1031,22 +1031,21 @@ create_folder (CamelStore *store, const char *parent_name, camel_exception_xfer (ex, &internal_ex); return NULL; } - + /* add the dirsep to the end of parent_name */ name = g_strdup_printf ("%s%c", parent_name, imap_store->dir_sep); response = camel_imap_command (imap_store, NULL, ex, "CREATE %F", name); g_free (name); - + if (!response) return NULL; else camel_imap_response_free (imap_store, response); } - /* ok now we can create the folder */ - + full_name = imap_concat (imap_store, parent_name, folder_name); response = camel_imap_command (imap_store, NULL, ex, "CREATE %F", full_name); @@ -1055,7 +1054,7 @@ create_folder (CamelStore *store, const char *parent_name, fi = get_folder_info_online (store, full_name, 0, ex); } else fi = NULL; - + g_free (full_name); return fi; } @@ -1068,10 +1067,10 @@ parse_list_response_as_folder_info (CamelImapStore *imap_store, int flags; char sep, *dir, *name = NULL; CamelURL *url; - + if (!imap_parse_list_response (imap_store, response, &flags, &sep, &dir)) return NULL; - + if (sep) { name = strrchr (dir, sep); if (name && !*++name) { @@ -1079,14 +1078,14 @@ parse_list_response_as_folder_info (CamelImapStore *imap_store, return NULL; } } - + fi = g_new0 (CamelFolderInfo, 1); fi->full_name = dir; if (sep && name) fi->name = g_strdup (name); else fi->name = g_strdup (dir); - + url = camel_url_new (imap_store->base_url, NULL); g_free (url->path); url->path = g_strdup_printf ("/%s", dir); @@ -1094,11 +1093,10 @@ parse_list_response_as_folder_info (CamelImapStore *imap_store, camel_url_set_param (url, "noselect", "yes"); fi->url = camel_url_to_string (url, 0); camel_url_free (url); - - + if (!(flags & IMAP_LIST_FLAG_UNMARKED)) fi->unread_message_count = -1; - + return fi; } @@ -1117,11 +1115,11 @@ get_subscribed_folders_by_hand (CamelImapStore *imap_store, const char *top, CamelFolderInfo *fi; char *result; int i, toplen = strlen (top); - + names = g_ptr_array_new (); g_hash_table_foreach (imap_store->subscribed_folders, copy_folder_name, names); - + for (i = 0; i < names->len; i++) { response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %F", @@ -1138,16 +1136,16 @@ get_subscribed_folders_by_hand (CamelImapStore *imap_store, const char *top, g_ptr_array_remove_index_fast (names, i--); continue; } - + fi = parse_list_response_as_folder_info (imap_store, result); if (!fi) continue; - + if (strncmp (top, fi->full_name, toplen) != 0) { camel_folder_info_free (fi); continue; } - + g_ptr_array_add (folders, fi); } g_ptr_array_free (names, TRUE); @@ -1161,13 +1159,13 @@ get_folders_online (CamelImapStore *imap_store, const char *pattern, CamelFolderInfo *fi; char *list; int i; - + response = camel_imap_command (imap_store, NULL, ex, "%s \"\" %F", lsub ? "LSUB" : "LIST", pattern); if (!response) return; - + for (i = 0; i < response->untagged->len; i++) { list = response->untagged->pdata[i]; fi = parse_list_response_as_folder_info (imap_store, list); diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index 944165aebb..648712a6ad 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -64,41 +64,41 @@ imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, ch { char *word; int len; - + if (*buf != '*') return FALSE; - + word = imap_next_word (buf); if (g_strncasecmp (word, "LIST", 4) && g_strncasecmp (word, "LSUB", 4)) return FALSE; - + /* get the flags */ word = imap_next_word (word); if (*word != '(') return FALSE; - + if (flags) *flags = 0; - + word++; while (*word != ')') { len = strcspn (word, " )"); if (flags) { - if (!g_strncasecmp (word, "\\Noinferiors", len)) + if (!g_strncasecmp (word, "\\NoInferiors", len)) *flags |= IMAP_LIST_FLAG_NOINFERIORS; - else if (!g_strncasecmp (word, "\\Noselect", len)) + else if (!g_strncasecmp (word, "\\NoSelect", len)) *flags |= IMAP_LIST_FLAG_NOSELECT; else if (!g_strncasecmp (word, "\\Marked", len)) *flags |= IMAP_LIST_FLAG_MARKED; else if (!g_strncasecmp (word, "\\Unmarked", len)) *flags |= IMAP_LIST_FLAG_UNMARKED; } - + word += len; while (*word == ' ') word++; } - + /* get the directory separator */ word = imap_next_word (word); if (!strncmp (word, "NIL", 3)) { @@ -114,11 +114,11 @@ imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, ch return FALSE; } else return FALSE; - + if (folder) { char *real_name; int n_len; - + /* get the folder name */ word = imap_next_word (word); real_name = imap_parse_astring (&word, &len); @@ -134,7 +134,7 @@ imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, ch g_free (real_name); return *folder != NULL; } - + return TRUE; } @@ -198,25 +198,25 @@ imap_parse_flag_list (char **flag_list_p) if (*flag_list == ' ') flag_list++; } - + if (*flag_list++ != ')') { *flag_list_p = NULL; return 0; } - + *flag_list_p = flag_list; return flags; } static char imap_atom_specials[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, }; #define imap_is_atom_char(ch) (isprint (ch) && !imap_atom_specials[ch]) @@ -246,18 +246,19 @@ imap_parse_string_generic (char **str_p, int *len, int type) { char *str = *str_p; char *out; - + if (!str) return NULL; else if (*str == '"') { char *p; int size; - + str++; size = strcspn (str, "\"") + 1; p = out = g_malloc (size); - - while (*str && *str != '"') { + + /* a quoted string cannot be broken into multiple lines */ + while (*str && *str != '"' && *str != '\n') { if (*str == '\\') str++; *p++ = *str++; @@ -290,11 +291,10 @@ imap_parse_string_generic (char **str_p, int *len, int type) *str_p += 3; *len = 0; return NULL; - } else if (type == IMAP_ASTRING && - imap_is_atom_char ((unsigned char)*str)) { + } else if (type == IMAP_ASTRING && imap_is_atom_char ((unsigned char)*str)) { while (imap_is_atom_char ((unsigned char)*str)) str++; - + *len = str - *str_p; str = g_strndup (*str_p, *len); *str_p += *len; @@ -319,7 +319,7 @@ static void skip_asn (char **str_p) { char *str = *str_p; - + if (!str) return; else if (*str == '"') { @@ -336,7 +336,7 @@ skip_asn (char **str_p) *str_p = NULL; } else if (*str == '{') { unsigned long len; - + len = strtoul (str + 1, &str, 10); if (*str != '}' || *(str + 1) != '\n' || strlen (str + 2) < len) { @@ -374,31 +374,31 @@ parse_params (char **parms_p, CamelContentType *type) { char *parms = *parms_p, *name, *value; int len; - + if (!g_strncasecmp (parms, "nil", 3)) { *parms_p += 3; return; } - + if (*parms++ != '(') { *parms_p = NULL; return; } - + while (parms && *parms != ')') { name = imap_parse_nstring (&parms, &len); skip_char (&parms, ' '); value = imap_parse_nstring (&parms, &len); - + if (name && value) header_content_type_set_param (type, name, value); g_free (name); g_free (value); - + if (parms && *parms == ' ') parms++; } - + if (!parms || *parms++ != ')') { *parms_p = NULL; return; @@ -424,18 +424,18 @@ imap_parse_body (char **body_p, CamelFolder *folder, CamelMessageContentInfo *child; CamelContentType *type; int len; - + if (*body++ != '(') { *body_p = NULL; return; } - + if (*body == '(') { /* multipart */ GPtrArray *children; char *subtype; int i; - + /* Parse the child body parts */ children = g_ptr_array_new (); i = 0; @@ -448,10 +448,10 @@ imap_parse_body (char **body_p, CamelFolder *folder, child->parent = ci; } skip_char (&body, ' '); - + /* Parse the multipart subtype */ subtype = imap_parse_string (&body, &len); - + /* If there is a parse error, abort. */ if (!body) { for (i = 0; i < children->len; i++) { @@ -462,11 +462,11 @@ imap_parse_body (char **body_p, CamelFolder *folder, *body_p = NULL; return; } - + g_strdown (subtype); ci->type = header_content_type_new ("multipart", subtype); g_free (subtype); - + /* Chain the children. */ ci->childs = children->pdata[0]; ci->size = 0; @@ -481,7 +481,7 @@ imap_parse_body (char **body_p, CamelFolder *folder, char *main_type, *subtype; char *id, *description, *encoding; guint32 size; - + main_type = imap_parse_string (&body, &len); skip_char (&body, ' '); subtype = imap_parse_string (&body, &len); @@ -499,7 +499,7 @@ imap_parse_body (char **body_p, CamelFolder *folder, g_free (subtype); parse_params (&body, type); skip_char (&body, ' '); - + id = imap_parse_nstring (&body, &len); skip_char (&body, ' '); description = imap_parse_nstring (&body, &len); @@ -508,7 +508,7 @@ imap_parse_body (char **body_p, CamelFolder *folder, skip_char (&body, ' '); if (body) size = strtoul (body, &body, 10); - + child = NULL; if (header_content_type_is (type, "message", "rfc822")) { skip_char (&body, ' '); @@ -525,7 +525,7 @@ imap_parse_body (char **body_p, CamelFolder *folder, if (body) strtoul (body, &body, 10); } - + if (body) { ci->type = type; ci->id = id; @@ -540,12 +540,12 @@ imap_parse_body (char **body_p, CamelFolder *folder, g_free (encoding); } } - + if (!body || *body++ != ')') { *body_p = NULL; return; } - + *body_p = body; } @@ -562,14 +562,14 @@ imap_quote_string (const char *str) const char *p; char *quoted, *q; int len; - + len = strlen (str); p = str; while ((p = strpbrk (p, "\"\\"))) { len++; p++; } - + quoted = q = g_malloc (len + 3); *q++ = '"'; while ((p = strpbrk (str, "\"\\"))) { @@ -580,7 +580,7 @@ imap_quote_string (const char *str) str = p; } sprintf (q, "%s\"", str); - + return quoted; } @@ -590,7 +590,7 @@ get_summary_uid_numeric (CamelFolderSummary *summary, int index) { CamelMessageInfo *info; unsigned long uid; - + info = camel_folder_summary_index (summary, index); uid = strtoul (camel_message_info_uid (info), NULL, 10); camel_folder_summary_info_free (summary, info); @@ -616,14 +616,14 @@ imap_uid_array_to_set (CamelFolderSummary *summary, GPtrArray *uids) gboolean range = FALSE; GString *gset; char *set; - + g_return_val_if_fail (uids->len > 0, NULL); - + gset = g_string_new (uids->pdata[0]); last_uid = strtoul (uids->pdata[0], NULL, 10); next_summary_uid = 0; scount = camel_folder_summary_count (summary); - + for (ui = 1, si = 0; ui < uids->len; ui++) { /* Find the next UID in the summary after the one we * just wrote out. @@ -632,7 +632,7 @@ imap_uid_array_to_set (CamelFolderSummary *summary, GPtrArray *uids) next_summary_uid = get_summary_uid_numeric (summary, si); if (last_uid >= next_summary_uid) next_summary_uid = (unsigned long) -1; - + /* Now get the next UID from @uids */ this_uid = strtoul (uids->pdata[ui], NULL, 10); if (this_uid == next_summary_uid || this_uid == last_uid + 1) @@ -644,16 +644,16 @@ imap_uid_array_to_set (CamelFolderSummary *summary, GPtrArray *uids) } g_string_sprintfa (gset, ",%lu", this_uid); } - + last_uid = this_uid; } - + if (range) g_string_sprintfa (gset, ":%lu", last_uid); - + set = gset->str; g_string_free (gset, FALSE); - + return set; } @@ -680,10 +680,10 @@ imap_uid_set_to_array (CamelFolderSummary *summary, const char *uids) char *p, *q; unsigned long uid, suid; int si, scount; - + arr = g_ptr_array_new (); scount = camel_folder_summary_count (summary); - + p = (char *)uids; si = 0; do { @@ -691,7 +691,7 @@ imap_uid_set_to_array (CamelFolderSummary *summary, const char *uids) if (p == q) goto lose; g_ptr_array_add (arr, g_strndup (p, q - p)); - + if (*q == ':') { /* Find the summary entry for the UID after the one * we just saw. @@ -703,11 +703,11 @@ imap_uid_set_to_array (CamelFolderSummary *summary, const char *uids) } if (si >= scount) suid = uid + 1; - + uid = strtoul (q + 1, &p, 10); if (p == q + 1) goto lose; - + /* Add each summary UID until we find one * larger than the end of the range */ @@ -721,9 +721,9 @@ imap_uid_set_to_array (CamelFolderSummary *summary, const char *uids) } else p = q; } while (*p++ == ','); - + return arr; - + lose: g_warning ("Invalid uid set %s", uids); imap_uid_array_free (arr); @@ -740,7 +740,7 @@ void imap_uid_array_free (GPtrArray *arr) { int i; - + for (i = 0; i < arr->len; i++) g_free (arr->pdata[i]); g_ptr_array_free (arr, TRUE); @@ -763,10 +763,9 @@ imap_namespace_concat (CamelImapStore *store, const char *name) { if (!name || *name == '\0') return g_strdup (store->namespace); - + if (!g_strcasecmp (name, "INBOX")) return g_strdup ("INBOX"); - + return imap_concat (store, store->namespace, name); } - diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 92d0abc9b0..f7749f4216 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -590,8 +590,8 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message, "sender address not valid.")); return FALSE; } - - camel_operation_start(NULL, _("Sending message")); + + camel_operation_start (NULL, _("Sending message")); /* find out if the message has 8bit mime parts */ has_8bit_parts = camel_mime_message_has_8bit_parts (CAMEL_MIME_MESSAGE (message)); @@ -612,7 +612,7 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message, recipient = (char *) r->data; if (!smtp_rcpt (smtp_transport, recipient, ex)) { g_free (recipient); - camel_operation_end(NULL); + camel_operation_end (NULL); return FALSE; } g_free (recipient); @@ -622,14 +622,14 @@ smtp_send_to (CamelTransport *transport, CamelMedium *message, recurse through the message all over again if the user is not sending 8bit mime parts */ if (!smtp_data (smtp_transport, message, has_8bit_parts, ex)) { - camel_operation_end(NULL); + camel_operation_end (NULL); return FALSE; } /* reset the service for our next transfer session */ smtp_rset (smtp_transport, ex); - - camel_operation_end(NULL); + + camel_operation_end (NULL); return TRUE; } @@ -682,8 +682,8 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) gchar *cmdbuf, *respbuf = NULL; struct hostent *host; - camel_operation_start_transient(NULL, _("SMTP Greeting")); - + camel_operation_start_transient (NULL, _("SMTP Greeting")); + /* get the local host name */ host = gethostbyaddr ((gchar *)&transport->localaddr.sin_addr, sizeof (transport->localaddr.sin_addr), AF_INET); @@ -706,7 +706,7 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("HELO request timed out: %s: non-fatal"), g_strerror (errno)); - camel_operation_end(NULL); + camel_operation_end (NULL); return FALSE; } g_free (cmdbuf); @@ -726,7 +726,7 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("HELO response error: %s: non-fatal"), get_smtp_error_string (error)); - camel_operation_end(NULL); + camel_operation_end (NULL); return FALSE; } @@ -744,8 +744,8 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) } } while (*(respbuf+3) == '-'); /* if we got "250-" then loop again */ g_free (respbuf); - - camel_operation_end(NULL); + + camel_operation_end (NULL); return TRUE; } @@ -754,19 +754,19 @@ static gboolean smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex) { gchar *cmdbuf, *respbuf = NULL, *challenge; - CamelSasl *sasl; - - camel_operation_start_transient(NULL, _("SMTP Authentication")); - + CamelSasl *sasl = NULL; + + camel_operation_start_transient (NULL, _("SMTP Authentication")); + sasl = camel_sasl_new ("smtp", mech, CAMEL_SERVICE (transport)); if (!sasl) { - camel_operation_end(NULL); + camel_operation_end (NULL); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Error creating SASL authentication object.")); return FALSE; } - - challenge = camel_sasl_challenge_base64(sasl, NULL, ex); + + challenge = camel_sasl_challenge_base64 (sasl, NULL, ex); if (challenge) { cmdbuf = g_strdup_printf ("AUTH %s %s\r\n", mech, challenge); g_free (challenge); @@ -830,10 +830,10 @@ smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex) g_free (respbuf); goto lose; } - - camel_object_unref((CamelObject *)sasl); - camel_operation_end(NULL); - + + camel_object_unref (CAMEL_OBJECT (sasl)); + camel_operation_end (NULL); + return TRUE; break_and_lose: @@ -850,7 +850,7 @@ smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex) } camel_object_unref (CAMEL_OBJECT (sasl)); - camel_operation_end(NULL); + camel_operation_end (NULL); return FALSE; } |