From: Timo Sirainen Date: Tue, 27 Oct 2015 21:56:48 +0000 (+0200) Subject: lib-mail, fts: Put application/xhtml+xml MIME parts through html parser as well. X-Git-Tag: 2.2.20.rc1~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=00a50d6dc74e15b5b83afcb8c12c2109a2ca376d;p=thirdparty%2Fdovecot%2Fcore.git lib-mail, fts: Put application/xhtml+xml MIME parts through html parser as well. --- diff --git a/src/lib-mail/mail-html2text.h b/src/lib-mail/mail-html2text.h index 7a2b54530c..6af484e33d 100644 --- a/src/lib-mail/mail-html2text.h +++ b/src/lib-mail/mail-html2text.h @@ -12,4 +12,11 @@ void mail_html2text_more(struct mail_html2text *ht, buffer_t *output); void mail_html2text_deinit(struct mail_html2text **ht); +static inline bool +mail_html2text_content_type_match(const char *content_type) +{ + return strcasecmp(content_type, "text/html") == 0 || + strcasecmp(content_type, "application/xhtml+xml") == 0; +} + #endif diff --git a/src/lib-mail/message-snippet.c b/src/lib-mail/message-snippet.c index 2446258791..f690bff468 100644 --- a/src/lib-mail/message-snippet.c +++ b/src/lib-mail/message-snippet.c @@ -115,7 +115,7 @@ int message_snippet_generate(struct istream *input, ct = message_decoder_current_content_type(decoder); if (ct == NULL) /* text/plain */ ; - else if (strcasecmp(ct, "text/html") == 0) { + else if (mail_html2text_content_type_match(ct)) { ctx.html2text = mail_html2text_init(MAIL_HTML2TEXT_FLAG_SKIP_QUOTED); ctx.plain_output = buffer_create_dynamic(pool, 1024); } else if (strncasecmp(ct, "text/", 5) != 0) diff --git a/src/lib-mail/test-message-snippet.c b/src/lib-mail/test-message-snippet.c index 2444a9b70d..af4683deaa 100644 --- a/src/lib-mail/test-message-snippet.c +++ b/src/lib-mail/test-message-snippet.c @@ -51,6 +51,20 @@ static struct { "
=\n", 100, "Hi, How is it going? > -foo" }, + + { "Content-Transfer-Encoding: quoted-printable\n" + "Content-Type: application/xhtml+xml;\n" + " charset=utf-8\n" + "\n" + "Hi,

How =\n" + "is it going?
quoted text is ignored
\n" + "> -foo\n" + "

=\n", + 100, + "Hi, How is it going? > -foo" }, }; static void test_message_snippet(void) diff --git a/src/plugins/fts/fts-parser-html.c b/src/plugins/fts/fts-parser-html.c index 1a5b2ae29d..b9c1d1e919 100644 --- a/src/plugins/fts/fts-parser-html.c +++ b/src/plugins/fts/fts-parser-html.c @@ -19,7 +19,7 @@ fts_parser_html_try_init(struct mail_user *user ATTR_UNUSED, { struct html_fts_parser *parser; - if (strcasecmp(content_type, "text/html") != 0) + if (!mail_html2text_content_type_match(content_type)) return NULL; parser = i_new(struct html_fts_parser, 1);