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
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)
"</div><br =class=3D\"\"></body></html>=\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"
+ "<html><head><meta http-equiv=3D\"Content-Type\" content=3D\"text/html =\n"
+ "charset=3Dutf-8\"></head><body style=3D\"word-wrap: break-word; =\n"
+ "-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\" =\n"
+ "class=3D\"\">Hi,<div class=3D\"\"><br class=3D\"\"></div><div class=3D\"\">How =\n"
+ "is it going? <blockquote>quoted text is ignored</blockquote>\n"
+ "> -foo\n"
+ "</div><br =class=3D\"\"></body></html>=\n",
+ 100,
+ "Hi, How is it going? > -foo" },
};
static void test_message_snippet(void)
{
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);