]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: test-message-header-encode - Add tests for broken UTF-8 in input.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 16 Sep 2020 02:31:58 +0000 (04:31 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 7 Oct 2020 14:08:11 +0000 (14:08 +0000)
src/lib-mail/test-message-header-encode.c

index 40caaeaaa77ad6d463452b5a9c9e0672ea04ccf2..b1c564510b2b36087d063bdce455560041b870b6 100644 (file)
@@ -194,7 +194,66 @@ static void test_message_header_encode(void)
                "a\r\n", "a",
                "a\n", "a",
                "foo\n \001bar", "foo\n =?utf-8?q?=01bar?=",
-               "foo\001\n bar", "=?utf-8?q?foo=01?=\n bar"
+               "foo\001\n bar", "=?utf-8?q?foo=01?=\n bar",
+               "\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4"
+               "\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4\xC3\xA4",
+                       "=?utf-8?b?w6TDpMOkw6TDpMOkw6TDpMOkw6TDpMOkw6TDpA==?=",
+               /* Bad UTF-8 */
+               "foofoo-\x80\x80\x80\x80\x80\x80\x80-barbar",
+                       "=?utf-8?q?foofoo-=EF=BF=BD-barbar?=",
+               "foobarfoobar-\x80\x80\x80\x80\x80\x80\x80",
+                       "=?utf-8?q?foobarfoobar-=EF=BF=BD?=",
+               "\x80\x80\x80\x80\x80\x80\x80-foobarfoobar",
+                       "=?utf-8?q?=EF=BF=BD-foobarfoobar?=",
+               "foofoo-\x80\x80\x80\x80\x80\x80\x80-barbarbarbar-"
+               "\x81\x82\x83\x84\x85\x86\x87-bazbaz",
+                       "=?utf-8?q?foofoo-=EF=BF=BD-barbarbarbar-"
+                       "=EF=BF=BD-bazbaz?=",
+               "foobarfoobarfoobar-\x80\x80\x80\x80\x80\x80\x80-"
+               "\x81\x82\x83\x84\x85\x86\x87-bazbaz",
+                       "=?utf-8?q?foobarfoobarfoobar-=EF=BF=BD-"
+                       "=EF=BF=BD-bazbaz?=",
+               "\x80\x80\x80\x80\x80\x80\x80-foobarfoobarfoobar-"
+               "\x81\x82\x83\x84\x85\x86\x87-bazbaz",
+                       "=?utf-8?q?=EF=BF=BD-foobarfoobarfoobar-"
+                       "=EF=BF=BD-bazbaz?=",
+               "foofoo-\xC3-barbar",
+                       "=?utf-8?q?foofoo-=EF=BF=BD-barbar?=",
+               "foobarfoobar-\xC3",
+                       "=?utf-8?q?foobarfoobar-=EF=BF=BD?=",
+               "\xC3-foobarfoobar",
+                       "=?utf-8?q?=EF=BF=BD-foobarfoobar?=",
+               "f-\x80\x80\x80\x80\x80\x80\x80-b", "=?utf-8?b?Zi3vv70tYg==?=",
+               "fb-\x80\x80\x80\x80\x80\x80\x80", "=?utf-8?b?ZmIt77+9?=",
+               "\x80\x80\x80\x80\x80\x80\x80-fb", "=?utf-8?b?77+9LWZi?=",
+               "ff-\x80\x80\x80\x80\x80\x80\x80-bb-"
+               "\x81\x82\x83\x84\x85\x86\x87-zz",
+                       "=?utf-8?b?ZmYt77+9LWJiLe+/vS16eg==?=",
+               "fbfb-\x80\x80\x80\x80\x80\x80\x80-"
+               "\x81\x82\x83\x84\x85\x86\x87-zz",
+                       "=?utf-8?b?ZmJmYi3vv70t77+9LXp6?=",
+               "\x80\x80\x80\x80\x80\x80\x80-ff-"
+               "\x81\x82\x83\x84\x85\x86\x87-zz",
+                       "=?utf-8?b?77+9LWZmLe+/vS16eg==?=",
+               "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80",
+                       "=?utf-8?b?77+9?=",
+               "-\xC3-\xC3-\xC3-\xC3-\xC3-\xC3-",
+                       "=?utf-8?q?-=EF=BF=BD-=EF=BF=BD-"
+                       "=EF=BF=BD-=EF=BF=BD-=EF=BF=BD-=EF=BF=BD-?=",
+               "\xC3--\xC3-\xC3-\xC3-\xC3--\xC3",
+                       "=?utf-8?q?=EF=BF=BD--=EF=BF=BD-"
+                       "=EF=BF=BD-=EF=BF=BD-=EF=BF=BD--=EF=BF=BD?=",
+               "-\xC3\xC3-\xC3\xC3-\xC3\xC3-\xC3\xC3-\xC3\xC3-\xC3\xC3-",
+                       "=?utf-8?b?Le+/vS3vv70t77+9Le+/vS3vv70t77+9LQ==?=",
+               "-\xC3\xC3\xC3-\xC3\xC3\xC3-\xC3\xC3\xC3-"
+               "\xC3\xC3\xC3-\xC3\xC3\xC3-\xC3\xC3\xC3-",
+                       "=?utf-8?b?Le+/vS3vv70t77+9Le+/vS3vv70t77+9LQ==?=",
+               "\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3\xC3",
+                       "=?utf-8?b?77+9?=",
+               "-\xC3\xA4\xC3\xC3-\xC3\xC3\xA4\xC3-\xC3\xC3\xC3\xA4-"
+               "\xC3\xC3\xC3\xA4-\xC3\xC3\xA4\xC3-\xC3\xA4\xC3\xC3-",
+                       "=?utf-8?b?LcOk77+9Le+/vcOk77+9Le+/"
+                       "vcOkLe+/vcOkLe+/vcOk77+9LcOk77+9LQ==?=",
        };                          
        string_t *str = t_str_new(128);
        unsigned int i;