fts_build_parse_content_disposition(ctx, hdr);
}
-static void
+static int
fts_build_unstructured_header(struct fts_mail_build_context *ctx,
const struct message_header_line *hdr)
{
const unsigned char *data = hdr->full_value;
unsigned char *buf = NULL;
unsigned int i;
+ int ret;
/* @UNSAFE: if there are any NULs, replace them with spaces */
for (i = 0; i < hdr->full_value_len; i++) {
buf[i] = data[i];
}
}
- (void)fts_build_data(ctx, data, hdr->full_value_len, TRUE);
+ ret = fts_build_data(ctx, data, hdr->full_value_len, TRUE);
i_free(buf);
+ return ret;
}
static bool data_has_8bit(const unsigned char *data, size_t size)
ctx->cur_user_lang = fts_user_get_data_lang(ctx->update_ctx->backend->ns->user);
}
-static void fts_build_mail_header(struct fts_mail_build_context *ctx,
- const struct message_block *block)
+static int fts_build_mail_header(struct fts_mail_build_context *ctx,
+ const struct message_block *block)
{
const struct message_header_line *hdr = block->hdr;
struct fts_backend_build_key key;
+ int ret;
if (hdr->eoh)
- return;
+ return 0;
/* hdr->full_value is always set because we get the block from
message_decoder */
fts_build_tokenized_hdr_update_lang(ctx, hdr);
if (!fts_backend_update_set_build_key(ctx->update_ctx, &key))
- return;
+ return 0;
if (!message_header_is_address(hdr->name)) {
/* regular unstructured header */
- fts_build_unstructured_header(ctx, hdr);
+ ret = fts_build_unstructured_header(ctx, hdr);
} else T_BEGIN {
/* message address. normalize it to give better
search results. */
str = t_str_new(hdr->full_value_len);
message_address_write(str, addr);
- (void)fts_build_data(ctx, str_data(str), str_len(str), TRUE);
+ ret = fts_build_data(ctx, str_data(str), str_len(str), TRUE);
} T_END;
if ((ctx->update_ctx->backend->flags &
/* index the header name itself */
key.hdr_name = "";
if (fts_backend_update_set_build_key(ctx->update_ctx, &key)) {
- (void)fts_build_data(ctx, (const void *)hdr->name,
- strlen(hdr->name), TRUE);
+ if (fts_build_data(ctx, (const void *)hdr->name,
+ strlen(hdr->name), TRUE) < 0)
+ ret = -1;
}
}
+ return ret;
}
static bool
if (block.hdr != NULL) {
fts_parse_mail_header(&ctx, &raw_block);
- fts_build_mail_header(&ctx, &block);
+ if (fts_build_mail_header(&ctx, &block) < 0) {
+ ret = -1;
+ break;
+ }
} else if (block.size == 0) {
/* end of headers */
} else {