bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
0b3e92b6043435c5aa9f1cf1d04b632f3e19abd9Phil Carmodystatic const struct fts_parser_vfuncs *parsers[] = {
657f76e8b68cac605c23171862f66f2bf070eed1Timo Sirainenstatic const char *plaintext_content_types[] = {
43f4e550efe7afa72aab3a7ded7ad7ce606526fbSergey Kitovbool fts_parser_init(struct fts_parser_context *parser_context,
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen unsigned int i;
43f4e550efe7afa72aab3a7ded7ad7ce606526fbSergey Kitov i_assert(parser_context->content_type != NULL);
43f4e550efe7afa72aab3a7ded7ad7ce606526fbSergey Kitov if (str_array_find(plaintext_content_types, parser_context->content_type)) {
4682f86ba3e1e019fc6f348d95cec17a429287cfTimo Sirainen /* we probably don't want/need to allow parsers to handle
4682f86ba3e1e019fc6f348d95cec17a429287cfTimo Sirainen plaintext? */
43f4e550efe7afa72aab3a7ded7ad7ce606526fbSergey Kitov *parser_r = parsers[i]->try_init(parser_context);
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainenstatic bool data_has_nuls(const unsigned char *data, size_t size)
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainen for (i = 0; i < size; i++) {
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainen data = buffer_get_modifiable_data(buf, &size);
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainen for (i = 0; i < size; i++) {
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainenvoid fts_parser_more(struct fts_parser *parser, struct message_block *block)
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainen if (!uni_utf8_data_is_valid(block->data, block->size) ||
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen /* output isn't valid UTF-8. make it. */
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen (void)uni_utf8_get_valid_data(block->data, block->size,
72d301f5751986396533088b769a9e74735a467cSergey Kitovint fts_parser_deinit(struct fts_parser **_parser, const char **retriable_err_msg_r)
3ad57148af55e45cc45401162d3460ed0b237a10Timo Sirainen unsigned int i;