dovecot-1.1: Threading code was using a copy of message_id_get_n...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jun 1 08:45:57 EEST 2009
details: http://hg.dovecot.org/dovecot-1.1/rev/b53614de6483
changeset: 8299:b53614de6483
user: Timo Sirainen <tss at iki.fi>
date: Mon Jun 01 01:45:53 2009 -0400
description:
Threading code was using a copy of message_id_get_next() code.
diffstat:
1 file changed, 5 insertions(+), 124 deletions(-)
src/imap/imap-thread.c | 129 +-----------------------------------------------
diffs (170 lines):
diff -r 553dce8f6185 -r b53614de6483 src/imap/imap-thread.c
--- a/src/imap/imap-thread.c Mon Jun 01 00:41:52 2009 -0400
+++ b/src/imap/imap-thread.c Mon Jun 01 01:45:53 2009 -0400
@@ -31,6 +31,7 @@
#include "hash.h"
#include "ostream.h"
#include "str.h"
+#include "message-id.h"
#include "rfc822-parser.h"
#include "imap-base-subject.h"
#include "mail-storage.h"
@@ -223,126 +224,6 @@ static struct node *update_message(struc
return node;
}
-static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid)
-{
- struct rfc822_parser_context parser;
-
- rfc822_parser_init(&parser, (const unsigned char *)*msgid_p,
- strlen(*msgid_p), NULL);
-
- /*
- msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
- id-left = dot-atom-text / no-fold-quote / obs-id-left
- id-right = dot-atom-text / no-fold-literal / obs-id-right
- no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE
- no-fold-literal = "[" *(dtext / quoted-pair) "]"
- */
-
- (void)rfc822_skip_lwsp(&parser);
-
- if (rfc822_parse_dot_atom(&parser, msgid) <= 0)
- return FALSE;
-
- if (*parser.data != '@')
- return FALSE;
- parser.data++;
- (void)rfc822_skip_lwsp(&parser);
-
- if (rfc822_parse_dot_atom(&parser, msgid) <= 0)
- return FALSE;
-
- if (*parser.data != '>')
- return FALSE;
-
- *msgid_p = (const char *)parser.data + 1;
- return TRUE;
-}
-
-static void strip_lwsp(char *str)
-{
- /* @UNSAFE */
- char *dest;
-
- /* find the first lwsp */
- while (*str != ' ' && *str != '\t' && *str != '\r' && *str != '\n') {
- if (*str == '\0')
- return;
- str++;
- }
-
- for (dest = str; *str != '\0'; str++) {
- if (*str != ' ' && *str != '\t' && *str != '\r' && *str != '\n')
- *dest++ = *str;
- }
- *dest = '\0';
-}
-
-static const char *get_msgid(const char **msgid_p)
-{
- const char *msgid = *msgid_p;
- const char *p;
- string_t *str = NULL;
- bool found_at;
-
- if (*msgid_p == NULL)
- return NULL;
-
- for (;;) {
- /* skip until '<' */
- while (*msgid != '<') {
- if (*msgid == '\0') {
- *msgid_p = msgid;
- return NULL;
- }
- msgid++;
- }
- msgid++;
-
- /* check it through quickly to see if it's already normalized */
- p = msgid; found_at = FALSE;
- for (;; p++) {
- if ((unsigned char)*p >= 'A') /* matches most */
- continue;
-
- if (*p == '@')
- found_at = TRUE;
- if (*p == '>' || *p == '"' || *p == '(' || *p == '[')
- break;
-
- if (*p == '\0') {
- *msgid_p = p;
- return NULL;
- }
- }
-
- if (*p == '>') {
- *msgid_p = p+1;
- if (found_at) {
- char *s;
-
- s = p_strdup_until(unsafe_data_stack_pool,
- msgid, p);
- strip_lwsp(s);
- return s;
- }
- } else {
- /* ok, do it the slow way */
- *msgid_p = msgid;
-
- if (str == NULL) {
- /* allocate only once, so we don't leak
- with multiple invalid message IDs */
- str = t_str_new(256);
- }
- if (get_untokenized_msgid(msgid_p, str))
- return str_c(str);
- }
-
- /* invalid message id, see if there's another valid one */
- msgid = *msgid_p;
- }
-}
-
static void unlink_child(struct thread_context *ctx,
struct node *child, bool add_to_root)
{
@@ -427,11 +308,11 @@ static bool link_references(struct threa
{
const char *parent_id, *child_id;
- parent_id = get_msgid(&references);
+ parent_id = message_id_get_next(&references);
if (parent_id == NULL)
return FALSE;
- while ((child_id = get_msgid(&references)) != NULL) {
+ while ((child_id = message_id_get_next(&references)) != NULL) {
link_message(ctx, parent_id, child_id, FALSE);
parent_id = child_id;
}
@@ -456,7 +337,7 @@ static void mail_thread_input(struct thr
if (mail_get_first_header(mail, "message-id", &message_id) < 0)
message_id = NULL;
- node = update_message(ctx, get_msgid(&message_id), sent_date,
+ node = update_message(ctx, message_id_get_next(&message_id), sent_date,
ctx->id_is_uid ? mail->uid : mail->seq);
/* link references */
@@ -468,7 +349,7 @@ static void mail_thread_input(struct thr
&in_reply_to) <= 0)
refid = NULL;
else
- refid = get_msgid(&in_reply_to);
+ refid = message_id_get_next(&in_reply_to);
if (refid != NULL)
link_node(ctx, refid, node, TRUE);
More information about the dovecot-cvs
mailing list