[dovecot-cvs] dovecot/src/lib-mail message-body-search.c, 1.16,
1.17 message-parser.c, 1.53, 1.54 message-parser.h, 1.24, 1.25
cras at procontrol.fi
cras at procontrol.fi
Fri Jun 18 00:28:25 EEST 2004
- Previous message: [dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c,1.26,1.27
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-parse.c,
1.11, 1.12 mbox-sync-private.h, 1.12, 1.13 mbox-sync-rewrite.c,
1.14, 1.15 mbox-sync-update.c, 1.11, 1.12 mbox-sync.c, 1.27, 1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv23807/lib-mail
Modified Files:
message-body-search.c message-parser.c message-parser.h
Log Message:
Added skip_initial_lwsp parameter to message_parse_header_init().
Index: message-body-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-body-search.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- message-body-search.c 10 Nov 2003 21:57:29 -0000 1.16
+++ message-body-search.c 17 Jun 2004 21:28:23 -0000 1.17
@@ -115,7 +115,7 @@
/* we default to text content-type */
ctx->content_type_text = TRUE;
- hdr_ctx = message_parse_header_init(input, NULL);
+ hdr_ctx = message_parse_header_init(input, NULL, TRUE);
while ((hdr = message_parse_header_next(hdr_ctx)) != NULL) {
if (hdr->eoh)
continue;
Index: message-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- message-parser.c 16 Jun 2004 05:36:59 -0000 1.53
+++ message-parser.c 17 Jun 2004 21:28:23 -0000 1.54
@@ -41,6 +41,7 @@
buffer_t *value_buf;
size_t skip;
+ int skip_initial_lwsp;
int has_nuls;
};
@@ -214,7 +215,7 @@
struct message_header_line *hdr;
hdr_ctx = message_parse_header_init(parser_ctx->input,
- &part->header_size);
+ &part->header_size, TRUE);
while ((hdr = message_parse_header_next(hdr_ctx)) != NULL) {
/* call the user-defined header parser */
if (parser_ctx->callback != NULL)
@@ -634,7 +635,7 @@
struct message_header_parser_ctx *hdr_ctx;
struct message_header_line *hdr;
- hdr_ctx = message_parse_header_init(input, hdr_size);
+ hdr_ctx = message_parse_header_init(input, hdr_size, TRUE);
while ((hdr = message_parse_header_next(hdr_ctx)) != NULL)
callback(part, hdr, context);
message_parse_header_deinit(hdr_ctx);
@@ -644,7 +645,8 @@
}
struct message_header_parser_ctx *
-message_parse_header_init(struct istream *input, struct message_size *hdr_size)
+message_parse_header_init(struct istream *input, struct message_size *hdr_size,
+ int skip_initial_lwsp)
{
struct message_header_parser_ctx *ctx;
@@ -652,6 +654,7 @@
ctx->input = input;
ctx->hdr_size = hdr_size;
ctx->name = str_new(default_pool, 128);
+ ctx->skip_initial_lwsp = skip_initial_lwsp;
if (hdr_size != NULL)
memset(hdr_size, 0, sizeof(*hdr_size));
@@ -776,7 +779,6 @@
if (msg[i] <= ':') {
if (msg[i] == ':') {
colon_pos = i;
- // FIXME: correct?
line->full_value_offset =
ctx->input->v_offset +
i + 1;
@@ -843,28 +845,37 @@
line->name = str_c(ctx->name);
line->name_len = str_len(ctx->name);
} else {
- /* get value. skip all LWSP after ':'. Note that RFC2822
- doesn't say we should, but history behind it..
+ size_t pos;
- Exception to this is if the value consists only of LWSP,
- then skip only the one LWSP after ':'. */
line->value = msg + colon_pos+1;
line->value_len = size - colon_pos - 1;
- while (line->value_len > 0 && IS_LWSP(line->value[0])) {
- line->value++;
- line->value_len--;
- }
+ if (ctx->skip_initial_lwsp) {
+ /* get value. skip all LWSP after ':'. Note that
+ RFC2822 doesn't say we should, but history behind
+ it..
- if (line->value_len == 0) {
- /* everything was LWSP */
- line->value = msg + colon_pos+1;
- line->value_len = size - colon_pos - 1;
- if (line->value_len > 0 && IS_LWSP(line->value[0])) {
- line->value++;
- line->value_len--;
+ Exception to this is if the value consists only of
+ LWSP, then skip only the one LWSP after ':'. */
+ for (pos = 0; pos < line->value_len; pos++) {
+ if (!IS_LWSP(line->value[0]))
+ break;
+ }
+
+ if (pos == line->value_len) {
+ /* everything was LWSP */
+ if (line->value_len > 0 &&
+ IS_LWSP(line->value[0]))
+ pos = 1;
}
+ } else {
+ pos = line->value_len > 0 &&
+ IS_LWSP(line->value[0]) ? 1 : 0;
}
+ line->value += pos;
+ line->value_len -= pos;
+ line->full_value_offset += pos;
+
/* get name, skip LWSP before ':' */
while (colon_pos > 0 && IS_LWSP(msg[colon_pos-1]))
colon_pos--;
Index: message-parser.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-parser.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- message-parser.h 27 Apr 2004 20:25:53 -0000 1.24
+++ message-parser.h 17 Jun 2004 21:28:23 -0000 1.25
@@ -47,7 +47,7 @@
const unsigned char *value;
size_t value_len;
- const unsigned char *full_value; // FIXME: should contain \n too
+ const unsigned char *full_value;
size_t full_value_len;
uoff_t name_offset, full_value_offset;
@@ -96,8 +96,13 @@
message_body_callback_t *body_callback,
void *context);
+/* skip_initial_lwsp controls if we should skip LWSP after "header: ".
+ Note that there may not be the single whitespace after "header:", and that
+ "header : " is also possible. These two conditions can't be determined from
+ struct message_header_line. */
struct message_header_parser_ctx *
-message_parse_header_init(struct istream *input, struct message_size *hdr_size);
+message_parse_header_init(struct istream *input, struct message_size *hdr_size,
+ int skip_initial_lwsp);
void message_parse_header_deinit(struct message_header_parser_ctx *ctx);
/* Read and return next header line. */
- Previous message: [dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c,1.26,1.27
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-parse.c,
1.11, 1.12 mbox-sync-private.h, 1.12, 1.13 mbox-sync-rewrite.c,
1.14, 1.15 mbox-sync-update.c, 1.11, 1.12 mbox-sync.c, 1.27, 1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list