/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "str.h" #include "istream.h" #include "unichar.h" #include "message-snippet.h" #include "test-common.h" static const struct { const char *input; unsigned int max_snippet_chars; const char *output; } tests[] = { { "Content-Type: text/plain\n" "\n" "1234567890 234567890", 12, "1234567890 2" }, { "Content-Type: text/plain\n" "\n" "line1\n>quote2\nline2\n", 100, "line1 line2" }, { "Content-Type: text/plain\n" "\n" "line1\n>quote2\n> quote3\n > line4\n\n \t\t \nline5\n \t ", 100, "line1 > line4 line5" }, { "Content-Type: text/plain; charset=utf-8\n" "\n" "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4\xC3\xA4", 11, "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4" }, { "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: quoted-printable\n" "\n" "hyv=C3=A4=C3=A4 p=C3=A4iv=C3=A4=C3=A4", 11, "hyv\xC3\xA4\xC3\xA4 p\xC3\xA4iv\xC3\xA4" }, { "Content-Transfer-Encoding: quoted-printable\n" "Content-Type: text/html;\n" " charset=utf-8\n" "\n" "
Hi,quoted text is ignored\n" "> -foo\n" "
quoted text is ignored\n" "> -foo\n" "
quoted text is included\n" "
part one
\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/html; charset=utf-8\n\n" "part two
\n" "\n--a--\n", 100, "part one" }, { "MIME-Version: 1.0\n" "Content-Type: multipart/alternative; boundary=a\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/html; charset=utf-8\n\n" "part one
\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/plain; charset=utf-8\n\n" "part two\n" "\n--a--\n", 100, "part one" }, { "MIME-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=a\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/html; charset=utf-8\n\n" "part two
\n" "\n--a--\n", 100, "part two" }, { "MIME-Version: 1.0\n" "Content-Type: multipart/alternative; boundary=a\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/plain; charset=utf-8\n\n" "> original text\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/plain; charset=utf-8\n\n" "part two\n" "\n--a--\n", 100, ">original text" }, { "MIME-Version: 1.0\n" "Content-Type: multipart/alternative; boundary=a\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/plain; charset=utf-8\n\n" "top poster\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/plain; charset=utf-8\n\n" "> original text\n" "\n--a--\n", 100, "top poster" }, { "MIME-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=a\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/html; charset=utf-8\n\n" "Should be in snippet
\n" "\n--a--\n", 100, "" }, { "MIME-Version: 1.0\n" "Content-Type: multipart/mixed; boundary=a\n" "\n--a\n" "Content-Transfer-Encoding: base64\n" "Content-Type: application/octet-stream\n\n" "U2hvdWxkIG5vdCBiZSBpbiBzbmlwcGV0\n" "\n--a\n" "Content-Transfer-Encoding: 7bit\n" "Content-Type: text/html; charset=utf-8\n\n" "