Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-imap/imap-bodystructure.c @ 7226:e6693a0ec8e1 HEAD
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
replaced them with T_BEGIN/END calls. T_FRAME() made it difficult to debug
code with gdb.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 11 Feb 2008 20:17:00 +0200 |
parents | 7ed926ed7aa4 |
children | 81806d402514 |
rev | line source |
---|---|
7086
7ed926ed7aa4
Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents:
7014
diff
changeset
|
1 /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */ |
0 | 2 |
3 #include "lib.h" | |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
4 #include "buffer.h" |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
647
diff
changeset
|
5 #include "istream.h" |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
6 #include "str.h" |
0 | 7 #include "message-parser.h" |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
8 #include "rfc822-parser.h" |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
9 #include "imap-parser.h" |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
10 #include "imap-quote.h" |
0 | 11 #include "imap-envelope.h" |
12 #include "imap-bodystructure.h" | |
13 | |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
14 #define DEFAULT_CHARSET \ |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
15 "\"charset\" \"us-ascii\"" |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
16 |
0 | 17 #define EMPTY_BODYSTRUCTURE \ |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
18 "(\"text\" \"plain\" ("DEFAULT_CHARSET") NIL NIL \"7bit\" 0 0)" |
0 | 19 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
20 struct message_part_body_data { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
21 pool_t pool; |
4816
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
22 const char *content_type, *content_subtype; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
23 const char *content_type_params; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
24 const char *content_transfer_encoding; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
25 const char *content_id; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
26 const char *content_description; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
27 const char *content_disposition; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
28 const char *content_disposition_params; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
29 const char *content_md5; |
8ac2a2d27364
Cleanup: Don't put string literals into non-const pointers.
Timo Sirainen <tss@iki.fi>
parents:
4280
diff
changeset
|
30 const char *content_language; |
0 | 31 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
32 struct message_part_envelope_data *envelope; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
33 }; |
0 | 34 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
35 static void parse_content_type(struct message_part_body_data *data, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
36 struct message_header_line *hdr) |
0 | 37 { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
38 struct rfc822_parser_context parser; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
39 const char *key, *value; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
40 string_t *str; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
41 unsigned int i; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
42 bool charset_found = FALSE; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
43 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
44 rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
45 (void)rfc822_skip_lwsp(&parser); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
46 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
47 str = t_str_new(256); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
48 if (rfc822_parse_content_type(&parser, str) < 0) |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
49 return; |
0 | 50 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
51 /* Save content type and subtype */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
52 value = str_c(str); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
53 for (i = 0; value[i] != '\0'; i++) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
54 if (value[i] == '/') { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
55 data->content_subtype = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
56 imap_quote(data->pool, str_data(str) + i + 1, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
57 str_len(str) - (i + 1)); |
0 | 58 break; |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
59 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
60 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
61 data->content_type = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
62 imap_quote(data->pool, str_data(str), i); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
63 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
64 /* parse parameters and save them */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
65 str_truncate(str, 0); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
66 while (rfc822_parse_content_param(&parser, &key, &value) > 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
67 if (strcasecmp(key, "charset") == 0) |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
68 charset_found = TRUE; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
69 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
70 str_append_c(str, ' '); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
71 imap_quote_append_string(str, key, TRUE); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
72 str_append_c(str, ' '); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
73 imap_quote_append_string(str, value, TRUE); |
0 | 74 } |
75 | |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
76 if (!charset_found && |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
77 strcasecmp(data->content_type, "\"text\"") == 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
78 /* set a default charset */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
79 str_append_c(str, ' '); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
80 str_append(str, DEFAULT_CHARSET); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
81 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
82 if (str_len(str) > 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
83 data->content_type_params = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
84 p_strdup(data->pool, str_c(str) + 1); |
896
21ffcce83c70
Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
85 } |
0 | 86 } |
87 | |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
88 static void parse_content_transfer_encoding(struct message_part_body_data *data, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
89 struct message_header_line *hdr) |
0 | 90 { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
91 struct rfc822_parser_context parser; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
92 string_t *str; |
0 | 93 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
94 rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
95 (void)rfc822_skip_lwsp(&parser); |
0 | 96 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
97 str = t_str_new(256); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
98 if (rfc822_parse_mime_token(&parser, str) >= 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
99 data->content_transfer_encoding = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
100 imap_quote(data->pool, str_data(str), str_len(str)); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
101 } |
0 | 102 } |
103 | |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
104 static void parse_content_disposition(struct message_part_body_data *data, |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
105 struct message_header_line *hdr) |
0 | 106 { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
107 struct rfc822_parser_context parser; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
108 const char *key, *value; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
109 string_t *str; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
110 |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
111 rfc822_parser_init(&parser, hdr->full_value, hdr->full_value_len, NULL); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
112 (void)rfc822_skip_lwsp(&parser); |
0 | 113 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
114 str = t_str_new(256); |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
115 if (rfc822_parse_mime_token(&parser, str) < 0) |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
116 return; |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
117 data->content_disposition = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
118 imap_quote(data->pool, str_data(str), str_len(str)); |
0 | 119 |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
120 /* parse parameters and save them */ |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
121 str_truncate(str, 0); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
122 while (rfc822_parse_content_param(&parser, &key, &value) > 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
123 str_append_c(str, ' '); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
124 imap_quote_append_string(str, key, TRUE); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
125 str_append_c(str, ' '); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
126 imap_quote_append_string(str, value, TRUE); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
127 } |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
128 if (str_len(str) > 0) { |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
129 data->content_disposition_params = |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
130 p_strdup(data->pool, str_c(str) + 1); |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
131 } |
0 | 132 } |
133 | |
898
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
897
diff
changeset
|
134 static void parse_content_language(const unsigned char *value, size_t value_len, |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
135 struct message_part_body_data *data) |
0 | 136 { |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
137 struct rfc822_parser_context parser; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
138 string_t *str; |
398
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
139 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
140 /* Language-Header = "Content-Language" ":" 1#Language-tag |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
141 Language-Tag = Primary-tag *( "-" Subtag ) |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
142 Primary-tag = 1*8ALPHA |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
143 Subtag = 1*8ALPHA */ |
0 | 144 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
145 rfc822_parser_init(&parser, value, value_len, NULL); |
0 | 146 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
147 str = t_str_new(128); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
148 str_append_c(str, '"'); |
0 | 149 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
150 (void)rfc822_skip_lwsp(&parser); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
151 while (rfc822_parse_atom(&parser, str) >= 0) { |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
152 str_append(str, "\" \""); |
398
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
153 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
154 if (parser.data == parser.end || *parser.data != ',') |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
155 break; |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
156 parser.data++; |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
157 (void)rfc822_skip_lwsp(&parser); |
398
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
158 } |
e807d88e653c
Parse Content-Language correctly for BODYSTRUCTURE.
Timo Sirainen <tss@iki.fi>
parents:
342
diff
changeset
|
159 |
3407
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
160 if (str_len(str) > 1) { |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
161 str_truncate(str, str_len(str) - 2); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
162 data->content_language = p_strdup(data->pool, str_c(str)); |
f484ad51ad9f
Make Content-Language parser use rfc822-parser API.
Timo Sirainen <tss@iki.fi>
parents:
2327
diff
changeset
|
163 } |
0 | 164 } |
165 | |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
166 static void parse_content_header(struct message_part_body_data *d, |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
167 struct message_header_line *hdr, |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
168 pool_t pool) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
169 { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
170 const char *name = hdr->name + strlen("Content-"); |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
171 const unsigned char *value; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
172 size_t value_len; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
173 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
174 if (hdr->continues) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
175 hdr->use_full_value = TRUE; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
176 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
177 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
178 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
179 value = hdr->full_value; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
180 value_len = hdr->full_value_len; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
181 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
182 switch (*name) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
183 case 'i': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
184 case 'I': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
185 if (strcasecmp(name, "ID") == 0 && d->content_id == NULL) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
186 d->content_id = imap_quote(pool, value, value_len); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
187 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
188 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
189 case 'm': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
190 case 'M': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
191 if (strcasecmp(name, "MD5") == 0 && d->content_md5 == NULL) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
192 d->content_md5 = imap_quote(pool, value, value_len); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
193 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
194 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
195 case 't': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
196 case 'T': |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
197 if (strcasecmp(name, "Type") == 0 && d->content_type == NULL) |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
198 parse_content_type(d, hdr); |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
199 if (strcasecmp(name, "Transfer-Encoding") == 0 && |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
200 d->content_transfer_encoding == NULL) |
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
201 parse_content_transfer_encoding(d, hdr); |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
202 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
203 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
204 case 'l': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
205 case 'L': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
206 if (strcasecmp(name, "Language") == 0 && |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
207 d->content_language == NULL) |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
208 parse_content_language(value, value_len, d); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
209 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
210 |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
211 case 'd': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
212 case 'D': |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
213 if (strcasecmp(name, "Description") == 0 && |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
214 d->content_description == NULL) { |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
215 d->content_description = |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
216 imap_quote(pool, value, value_len); |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
217 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
218 if (strcasecmp(name, "Disposition") == 0 && |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
219 d->content_disposition_params == NULL) { |
6117
9214044ce1f1
Removed message-content-parser. Instead added rfc822_parse_content_type()
Timo Sirainen <tss@iki.fi>
parents:
5836
diff
changeset
|
220 parse_content_disposition(d, hdr); |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
221 } |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
222 break; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
223 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
224 } |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
225 |
1689
c07b98265577
If BODY/BODYSTRUCTURE is requested with some other headers, parse the
Timo Sirainen <tss@iki.fi>
parents:
1665
diff
changeset
|
226 void imap_bodystructure_parse_header(pool_t pool, struct message_part *part, |
c07b98265577
If BODY/BODYSTRUCTURE is requested with some other headers, parse the
Timo Sirainen <tss@iki.fi>
parents:
1665
diff
changeset
|
227 struct message_header_line *hdr) |
0 | 228 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
229 struct message_part_body_data *part_data; |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
230 struct message_part_envelope_data *envelope; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
231 bool parent_rfc822; |
0 | 232 |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
233 if (hdr == NULL) { |
7014
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
234 if (part->context == NULL) { |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
235 /* no Content-* headers. add an empty context |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
236 structure anyway. */ |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
237 part->context = part_data = |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
238 p_new(pool, struct message_part_body_data, 1); |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
239 part_data->pool = pool; |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
240 } else if ((part->flags & MESSAGE_PART_FLAG_IS_MIME) == 0) { |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
241 /* If there was no Mime-Version, forget all |
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
242 the Content-stuff */ |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
243 part_data = part->context; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
244 envelope = part_data->envelope; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
245 |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
246 memset(part_data, 0, sizeof(*part_data)); |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
247 part_data->pool = pool; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
248 part_data->envelope = envelope; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
249 } |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
250 return; |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
251 } |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
252 |
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
253 if (hdr->eoh) |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
254 return; |
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
255 |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
105
diff
changeset
|
256 parent_rfc822 = part->parent != NULL && |
1619
5bdda4147b36
Fixes for handling missing Mime-Version
Timo Sirainen <tss@iki.fi>
parents:
1618
diff
changeset
|
257 (part->parent->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0; |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
258 if (!parent_rfc822 && strncasecmp(hdr->name, "Content-", 8) != 0) |
0 | 259 return; |
260 | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
261 if (part->context == NULL) { |
0 | 262 /* initialize message part data */ |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
263 part->context = part_data = |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
264 p_new(pool, struct message_part_body_data, 1); |
0 | 265 part_data->pool = pool; |
266 } | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
267 part_data = part->context; |
0 | 268 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
269 if (strncasecmp(hdr->name, "Content-", 8) == 0) { |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
270 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
271 parse_content_header(part_data, hdr, pool); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
272 } T_END; |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
273 } |
898
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
897
diff
changeset
|
274 |
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
897
diff
changeset
|
275 if (parent_rfc822) { |
0 | 276 /* message/rfc822, we need the envelope */ |
1322
97f8c00b8d4c
Better handling for multiline headers. Before we skipped headers larger than
Timo Sirainen <tss@iki.fi>
parents:
1257
diff
changeset
|
277 imap_envelope_parse_header(pool, &part_data->envelope, hdr); |
0 | 278 } |
279 } | |
280 | |
5334
8d9234a26a3f
Make imap_bodystructure_write() parameter constant. Patch by Max Kellermann
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
281 static void part_write_body_multipart(const struct message_part *part, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
282 string_t *str, bool extended) |
0 | 283 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
284 struct message_part_body_data *data = part->context; |
0 | 285 |
286 if (part->children != NULL) | |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
287 imap_bodystructure_write(part->children, str, extended); |
0 | 288 else { |
289 /* no parts in multipart message, | |
290 that's not allowed. write a single | |
291 0-length text/plain structure */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
292 str_append(str, EMPTY_BODYSTRUCTURE); |
0 | 293 } |
294 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
295 str_append_c(str, ' '); |
647
1acbf6c8758c
handle broken multipart messages without crashing
Timo Sirainen <tss@iki.fi>
parents:
593
diff
changeset
|
296 if (data->content_subtype != NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
297 str_append(str, data->content_subtype); |
647
1acbf6c8758c
handle broken multipart messages without crashing
Timo Sirainen <tss@iki.fi>
parents:
593
diff
changeset
|
298 else |
896
21ffcce83c70
Rewrote rfc822-tokenize.c to work one token at a time so it won't uselessly
Timo Sirainen <tss@iki.fi>
parents:
877
diff
changeset
|
299 str_append(str, "\"x-unknown\""); |
0 | 300 |
301 if (!extended) | |
302 return; | |
303 | |
304 /* BODYSTRUCTURE data */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
305 str_append_c(str, ' '); |
0 | 306 if (data->content_type_params == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
307 str_append(str, "NIL"); |
0 | 308 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
309 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
310 str_append(str, data->content_type_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
311 str_append_c(str, ')'); |
0 | 312 } |
313 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
314 str_append_c(str, ' '); |
0 | 315 if (data->content_disposition == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
316 str_append(str, "NIL"); |
0 | 317 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
318 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
319 str_append(str, data->content_disposition); |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
320 str_append_c(str, ' '); |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
321 |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
322 if (data->content_disposition_params == NULL) |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
323 str_append(str, "NIL"); |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
324 else { |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
325 str_append_c(str, '('); |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
326 str_append(str, data->content_disposition_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
327 str_append_c(str, ')'); |
0 | 328 } |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
329 str_append_c(str, ')'); |
0 | 330 } |
331 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
332 str_append_c(str, ' '); |
0 | 333 if (data->content_language == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
334 str_append(str, "NIL"); |
0 | 335 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
336 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
337 str_append(str, data->content_language); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
338 str_append_c(str, ')'); |
0 | 339 } |
340 } | |
341 | |
5334
8d9234a26a3f
Make imap_bodystructure_write() parameter constant. Patch by Max Kellermann
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
342 static void part_write_body(const struct message_part *part, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
343 string_t *str, bool extended) |
0 | 344 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
345 struct message_part_body_data *data = part->context; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
346 bool text; |
0 | 347 |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
348 if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) { |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
349 str_append(str, "\"message\" \"rfc822\""); |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
350 text = FALSE; |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
351 } else { |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
352 /* "content type" "subtype" */ |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
353 text = data->content_type == NULL || |
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
354 strcasecmp(data->content_type, "\"text\"") == 0; |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
355 str_append(str, NVL(data->content_type, "\"text\"")); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
356 str_append_c(str, ' '); |
1255
58041ce0a24c
Default to 7bit instead of 8bit content-encoding-type.
Timo Sirainen <tss@iki.fi>
parents:
1107
diff
changeset
|
357 |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
358 if (data->content_subtype != NULL) |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
359 str_append(str, data->content_subtype); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
360 else { |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
361 if (text) |
1665
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
362 str_append(str, "\"plain\""); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
363 else |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
364 str_append(str, "\"unknown\""); |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
365 |
e50e21588020
Some message/rfc822 mails were returned as text/plain
Timo Sirainen <tss@iki.fi>
parents:
1664
diff
changeset
|
366 } |
1255
58041ce0a24c
Default to 7bit instead of 8bit content-encoding-type.
Timo Sirainen <tss@iki.fi>
parents:
1107
diff
changeset
|
367 } |
0 | 368 |
369 /* ("content type param key" "value" ...) */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
370 str_append_c(str, ' '); |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
371 if (data->content_type_params == NULL) { |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
372 if (!text) |
1537
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
373 str_append(str, "NIL"); |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
374 else |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
375 str_append(str, "("DEFAULT_CHARSET")"); |
d4563a5ba30b
Add charset/us-ascii into body/bodystructure replies if no charset is given
Timo Sirainen <tss@iki.fi>
parents:
1327
diff
changeset
|
376 } else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
377 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
378 str_append(str, data->content_type_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
379 str_append_c(str, ')'); |
0 | 380 } |
381 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
382 str_printfa(str, " %s %s %s %"PRIuUOFF_T, |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
383 NVL(data->content_id, "NIL"), |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
384 NVL(data->content_description, "NIL"), |
1255
58041ce0a24c
Default to 7bit instead of 8bit content-encoding-type.
Timo Sirainen <tss@iki.fi>
parents:
1107
diff
changeset
|
385 NVL(data->content_transfer_encoding, "\"7bit\""), |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
386 part->body_size.virtual_size); |
0 | 387 |
2327
7d02e2a7672d
Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents:
2298
diff
changeset
|
388 if (text) { |
0 | 389 /* text/.. contains line count */ |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
390 str_printfa(str, " %u", part->body_size.lines); |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
105
diff
changeset
|
391 } else if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) { |
0 | 392 /* message/rfc822 contains envelope + body + line count */ |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
393 struct message_part_body_data *child_data; |
1663
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
394 struct message_part_envelope_data *env_data; |
0 | 395 |
396 i_assert(part->children != NULL); | |
397 i_assert(part->children->next == NULL); | |
398 | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
399 child_data = part->children->context; |
7014
6835ac721609
Add a context structure to all message parts and remove the NULL checks.
Timo Sirainen <tss@iki.fi>
parents:
6940
diff
changeset
|
400 env_data = child_data->envelope; |
0 | 401 |
1664 | 402 str_append(str, " ("); |
1663
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
403 imap_envelope_write_part_data(env_data, str); |
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
404 str_append(str, ") "); |
4aca99baa9a4
Don't write envelope as NIL into bodystructure even if it's broken.
Timo Sirainen <tss@iki.fi>
parents:
1661
diff
changeset
|
405 |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
406 imap_bodystructure_write(part->children, str, extended); |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
407 str_printfa(str, " %u", part->body_size.lines); |
0 | 408 } |
409 | |
410 if (!extended) | |
411 return; | |
412 | |
413 /* BODYSTRUCTURE data */ | |
414 | |
415 /* "md5" ("content disposition" ("disposition" "params")) | |
416 ("body" "language" "params") */ | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
417 str_append_c(str, ' '); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
418 str_append(str, NVL(data->content_md5, "NIL")); |
0 | 419 |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
420 str_append_c(str, ' '); |
0 | 421 if (data->content_disposition == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
422 str_append(str, "NIL"); |
0 | 423 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
424 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
425 str_append(str, data->content_disposition); |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
426 str_append_c(str, ' '); |
0 | 427 |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
428 if (data->content_disposition_params == NULL) |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
429 str_append(str, "NIL"); |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
430 else { |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
431 str_append_c(str, '('); |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
432 str_append(str, data->content_disposition_params); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
433 str_append_c(str, ')'); |
0 | 434 } |
862
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
435 |
375923d2f910
BODYSTRUCTURE reply was incorrect. pine didn't like it.
Timo Sirainen <tss@iki.fi>
parents:
833
diff
changeset
|
436 str_append_c(str, ')'); |
0 | 437 } |
438 | |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
439 str_append_c(str, ' '); |
0 | 440 if (data->content_language == NULL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
441 str_append(str, "NIL"); |
0 | 442 else { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
443 str_append_c(str, '('); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
444 str_append(str, data->content_language); |
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
445 str_append_c(str, ')'); |
0 | 446 } |
447 } | |
448 | |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
449 bool imap_bodystructure_is_plain_7bit(struct message_part *part) |
3460
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
450 { |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
451 struct message_part_body_data *data = part->context; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
452 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
453 i_assert(part->parent == NULL); |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
454 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
455 /* if content-type is text/xxx we don't have to check any |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
456 multipart stuff */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
457 if ((part->flags & MESSAGE_PART_FLAG_TEXT) == 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
458 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
459 if (part->next != NULL || part->children != NULL) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
460 return FALSE; /* shouldn't happen normally.. */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
461 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
462 /* must be text/plain */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
463 if (data->content_subtype != NULL && |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
464 strcasecmp(data->content_subtype, "\"plain\"") != 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
465 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
466 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
467 /* only allowed parameter is charset=us-ascii, which is also default */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
468 if (data->content_type_params != NULL && |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
469 strcasecmp(data->content_type_params, DEFAULT_CHARSET) != 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
470 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
471 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
472 if (data->content_id != NULL || |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
473 data->content_description != NULL) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
474 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
475 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
476 if (data->content_transfer_encoding != NULL && |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
477 strcasecmp(data->content_transfer_encoding, "\"7bit\"") != 0) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
478 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
479 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
480 /* BODYSTRUCTURE checks: */ |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
481 if (data->content_md5 != NULL || |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
482 data->content_disposition != NULL || |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
483 data->content_language != NULL) |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
484 return FALSE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
485 |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
486 return TRUE; |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
487 } |
e8cbf3ae00db
Added imap_bodystructure_is_plain_7bit()
Timo Sirainen <tss@iki.fi>
parents:
3407
diff
changeset
|
488 |
5334
8d9234a26a3f
Make imap_bodystructure_write() parameter constant. Patch by Max Kellermann
Timo Sirainen <tss@iki.fi>
parents:
4903
diff
changeset
|
489 void imap_bodystructure_write(const struct message_part *part, |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
490 string_t *dest, bool extended) |
0 | 491 { |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
492 i_assert(part->parent != NULL || part->next == NULL); |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
493 |
0 | 494 while (part != NULL) { |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
495 if (part->parent != NULL) |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
496 str_append_c(dest, '('); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
497 |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
105
diff
changeset
|
498 if (part->flags & MESSAGE_PART_FLAG_MULTIPART) |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
499 part_write_body_multipart(part, dest, extended); |
0 | 500 else |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
501 part_write_body(part, dest, extended); |
0 | 502 |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
503 if (part->parent != NULL) |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
504 str_append_c(dest, ')'); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
505 |
0 | 506 part = part->next; |
507 } | |
508 } | |
509 | |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
510 static bool str_append_imap_arg(string_t *str, const struct imap_arg *arg) |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
511 { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
512 switch (arg->type) { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
513 case IMAP_ARG_NIL: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
514 str_append(str, "NIL"); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
515 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
516 case IMAP_ARG_ATOM: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
517 str_append(str, IMAP_ARG_STR(arg)); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
518 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
519 case IMAP_ARG_STRING: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
520 str_append_c(str, '"'); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
521 str_append(str, IMAP_ARG_STR(arg)); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
522 str_append_c(str, '"'); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
523 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
524 case IMAP_ARG_LITERAL: { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
525 const char *argstr = IMAP_ARG_STR(arg); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
526 |
4280
92bf418b8a60
BODYSTRUCTURE -> BODY translation was missing CRLF after literal.
Timo Sirainen <tss@iki.fi>
parents:
4070
diff
changeset
|
527 str_printfa(str, "{%"PRIuSIZE_T"}\r\n", strlen(argstr)); |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
528 str_append(str, argstr); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
529 break; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
530 } |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
531 default: |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
532 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
533 } |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
534 |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
535 return TRUE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
536 } |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
537 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
538 static bool imap_write_list(const struct imap_arg *args, string_t *str) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
539 { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
540 /* don't do any typechecking, just write it out */ |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
541 str_append_c(str, '('); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
542 while (args->type != IMAP_ARG_EOL) { |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
543 if (!str_append_imap_arg(str, args)) { |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
544 if (args->type != IMAP_ARG_LIST) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
545 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
546 |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
547 if (!imap_write_list(IMAP_ARG_LIST_ARGS(args), str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
548 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
549 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
550 args++; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
551 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
552 if (args->type != IMAP_ARG_EOL) |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
553 str_append_c(str, ' '); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
554 } |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
555 str_append_c(str, ')'); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
556 return TRUE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
557 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
558 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
559 static bool imap_parse_bodystructure_args(const struct imap_arg *args, |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
560 string_t *str) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
561 { |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5334
diff
changeset
|
562 const struct imap_arg *subargs; |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
563 const struct imap_arg *list_args; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
564 bool multipart, text, message_rfc822; |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
565 int i; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
566 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
567 multipart = FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
568 while (args->type == IMAP_ARG_LIST) { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
569 str_append_c(str, '('); |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
570 list_args = IMAP_ARG_LIST_ARGS(args); |
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
571 if (!imap_parse_bodystructure_args(list_args, str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
572 return FALSE; |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
573 str_append_c(str, ')'); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
574 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
575 multipart = TRUE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
576 args++; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
577 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
578 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
579 if (multipart) { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
580 /* next is subtype of Content-Type. rest is skipped. */ |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
581 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
582 return str_append_imap_arg(str, args); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
583 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
584 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
585 /* "content type" "subtype" */ |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
586 if (args[0].type == IMAP_ARG_NIL || args[1].type == IMAP_ARG_NIL) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
587 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
588 |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
589 if (!str_append_imap_arg(str, &args[0])) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
590 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
591 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
592 if (!str_append_imap_arg(str, &args[1])) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
593 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
594 |
3571 | 595 text = strcasecmp(IMAP_ARG_STR_NONULL(&args[0]), "text") == 0; |
596 message_rfc822 = | |
597 strcasecmp(IMAP_ARG_STR_NONULL(&args[0]), "message") == 0 && | |
598 strcasecmp(IMAP_ARG_STR_NONULL(&args[1]), "rfc822") == 0; | |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
599 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
600 args += 2; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
601 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
602 /* ("content type param key" "value" ...) | NIL */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
603 if (args->type == IMAP_ARG_LIST) { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
604 str_append(str, " ("); |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
605 subargs = IMAP_ARG_LIST_ARGS(args); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
606 for (; subargs->type != IMAP_ARG_EOL; ) { |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
607 if (!str_append_imap_arg(str, &subargs[0])) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
608 return FALSE; |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
609 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
610 if (!str_append_imap_arg(str, &subargs[1])) |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
611 return FALSE; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
612 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
613 subargs += 2; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
614 if (subargs->type == IMAP_ARG_EOL) |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
615 break; |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
616 str_append_c(str, ' '); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
617 } |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
618 str_append(str, ")"); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
619 } else if (args->type == IMAP_ARG_NIL) { |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
620 str_append(str, " NIL"); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
621 } else { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
622 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
623 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
624 args++; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
625 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
626 /* "content id" "content description" "transfer encoding" size */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
627 for (i = 0; i < 4; i++, args++) { |
1107
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
628 str_append_c(str, ' '); |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
629 |
4044c2903ed7
Don't do x-unknown mime encoding. Correct way is to just send them as
Timo Sirainen <tss@iki.fi>
parents:
913
diff
changeset
|
630 if (!str_append_imap_arg(str, args)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
631 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
632 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
633 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
634 if (text) { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
635 /* text/xxx - text lines */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
636 if (args->type != IMAP_ARG_ATOM) |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
637 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
638 |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
639 str_append_c(str, ' '); |
877
7935347f54f1
Don't access ImapArg's union members directly - too easy to mess up. Fixes a
Timo Sirainen <tss@iki.fi>
parents:
862
diff
changeset
|
640 str_append(str, IMAP_ARG_STR(args)); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
641 } else if (message_rfc822) { |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
642 /* message/rfc822 - envelope + bodystructure + text lines */ |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
643 if (args[0].type != IMAP_ARG_LIST || |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
644 args[1].type != IMAP_ARG_LIST || |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
645 args[2].type != IMAP_ARG_ATOM) |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
646 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
647 |
833
41ec8cadd238
Replaced TempString with a String which can use any memory pool and uses
Timo Sirainen <tss@iki.fi>
parents:
768
diff
changeset
|
648 str_append_c(str, ' '); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
649 |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
650 list_args = IMAP_ARG_LIST_ARGS(&args[0]); |
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
651 if (!imap_write_list(list_args, str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
652 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
653 |
4027
0e7a9b0aa8c3
BODYSTRUCTURE -> BODY conversion was broken with mails containing
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
654 str_append(str, " ("); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
655 |
5836
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
656 list_args = IMAP_ARG_LIST_ARGS(&args[1]); |
9f869a7a3d73
Changed imap-parser API to use standard arrays for lists instead of its own
Timo Sirainen <tss@iki.fi>
parents:
5835
diff
changeset
|
657 if (!imap_parse_bodystructure_args(list_args, str)) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
658 return FALSE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
659 |
4027
0e7a9b0aa8c3
BODYSTRUCTURE -> BODY conversion was broken with mails containing
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
660 str_append(str, ") "); |
877
7935347f54f1
Don't access ImapArg's union members directly - too easy to mess up. Fixes a
Timo Sirainen <tss@iki.fi>
parents:
862
diff
changeset
|
661 str_append(str, IMAP_ARG_STR(&args[2])); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
662 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
663 |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
664 return TRUE; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
665 } |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
666 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
667 bool imap_body_parse_from_bodystructure(const char *bodystructure, |
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3571
diff
changeset
|
668 string_t *dest) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
669 { |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
670 struct istream *input; |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
898
diff
changeset
|
671 struct imap_parser *parser; |
5835
d59ed6a31b66
Added more consts to imap-parser API
Timo Sirainen <tss@iki.fi>
parents:
5334
diff
changeset
|
672 const struct imap_arg *args; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
673 int ret; |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
674 |
6142
6c0bfc35af03
Removed memory pool parameter from iostreams. Default pool was almost always
Timo Sirainen <tss@iki.fi>
parents:
6117
diff
changeset
|
675 input = i_stream_create_from_data(bodystructure, strlen(bodystructure)); |
764
f57c52738f90
Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents:
647
diff
changeset
|
676 (void)i_stream_read(input); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
677 |
1591
6eca99b727a0
IMAP parser memory limits are now enforced by bytes per line rather than
Timo Sirainen <tss@iki.fi>
parents:
1568
diff
changeset
|
678 parser = imap_parser_create(input, NULL, (size_t)-1); |
1661
566fb4bf7066
Fixes for parsing BODYSTRUCTURE
Timo Sirainen <tss@iki.fi>
parents:
1619
diff
changeset
|
679 ret = imap_parser_finish_line(parser, 0, IMAP_PARSE_FLAG_NO_UNESCAPE | |
566fb4bf7066
Fixes for parsing BODYSTRUCTURE
Timo Sirainen <tss@iki.fi>
parents:
1619
diff
changeset
|
680 IMAP_PARSE_FLAG_LITERAL_TYPE, &args); |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
681 ret = ret > 0 && imap_parse_bodystructure_args(args, dest); |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
682 |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
683 if (!ret) |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
684 i_error("Error parsing IMAP bodystructure: %s", bodystructure); |
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
685 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
686 imap_parser_destroy(&parser); |
4070
71b8faa84ec6
Added i_stream_destroy() and o_stream_destroy() and used them instead of
Timo Sirainen <tss@iki.fi>
parents:
4027
diff
changeset
|
687 i_stream_destroy(&input); |
2298
5beb0c20b6e8
Cache file fixes, API changes, etc. It's still in somewhat ugly state, but
Timo Sirainen <tss@iki.fi>
parents:
1782
diff
changeset
|
688 return ret; |
445
8179ef2a2c62
If BODYSTRUCTURE is cached, we can use it to generate BODY reply. It takes
Timo Sirainen <tss@iki.fi>
parents:
410
diff
changeset
|
689 } |