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