/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "base64.h"
#include "buffer.h"
#include "str.h"
#include "message-header-encode.h"
#include "test-common.h"
{
i += 2;
line_start = i - 1;
}
for (;;) {
return FALSE;
i += 10;
if (starts_with_a) {
if (str[i] != 'a')
return FALSE;
i++;
}
return FALSE;
i += 6;
char_count++;
}
i += 2;
if (i - line_start > 76)
return FALSE;
if (str[i] == '\0')
break;
return FALSE;
i += 2;
line_start = i - 1;
}
return char_count == 40;
}
static void test_message_header_encode_q(void)
{
unsigned int i, j, skip;
test_begin("message header encode q");
for (i = 0; i < 40; i++)
for (i = 0; i < 80; i++) {
str_truncate(str, 0);
for (j = 1; j < i; j++)
if (i != 0)
i == 0 ? 0 : i+1);
}
}
test_end();
}
{
i += 2;
line_start = i - 1;
}
for (;;) {
return FALSE;
i += 10;
start = i;
for (; str[i] != '?'; i++) {
if (str[i] == '\0')
return FALSE;
}
buffer_set_used_size(&buf, 0);
return FALSE;
i++;
if (!starts_with_a)
j = 0;
else {
if (bufdata[0] != 'a')
return FALSE;
j = 1;
}
return FALSE;
char_count++;
}
return FALSE;
if (str[i++] != '=')
return FALSE;
if (i - line_start > 76)
return FALSE;
if (str[i] == '\0')
break;
return FALSE;
i += 2;
line_start = i - 1;
}
return char_count == 40;
}
static void test_message_header_encode_b(void)
{
unsigned int i, j, skip;
test_begin("message header encode b");
for (i = 0; i < 40; i++)
for (i = 0; i < 80; i++) {
str_truncate(str, 0);
for (j = 1; j < i; j++)
if (i != 0)
i == 0 ? 0 : i+1);
}
}
test_end();
}
static void test_message_header_encode(void)
{
const char *data[] = {
"a b", "a b",
"a bc\xC3\xA4""de f", "a =?utf-8?q?bc=C3=A4de?= f",
"a \xC3\xA4\xC3\xA4 \xC3\xA4 b", "a =?utf-8?b?w6TDpCDDpA==?= b",
"\xC3\xA4 a \xC3\xA4", "=?utf-8?q?=C3=A4_a_=C3=A4?=",
"\xC3\xA4\xC3\xA4 a \xC3\xA4", "=?utf-8?b?w6TDpCBhIMOk?=",
"=", "=",
"?", "?",
"a=?", "a=?",
"=?", "=?utf-8?q?=3D=3F?=",
"=?x", "=?utf-8?q?=3D=3Fx?=",
"a\n=?", "a\n\t=?utf-8?q?=3D=3F?=",
"a\t=?", "a\t=?utf-8?q?=3D=3F?=",
"a =?", "a =?utf-8?q?=3D=3F?=",
"foo\001bar", "=?utf-8?q?foo=01bar?=",
"\x01\x02\x03\x04\x05\x06\x07\x08", "=?utf-8?b?AQIDBAUGBwg=?=",
"a\r\n b", "a\r\n b",
"a\r\n\tb", "a\r\n\tb",
"a\r\nb", "a\r\n\tb",
"a\n b", "a\n b",
"a\n b", "a\n b",
"a\nb", "a\n\tb",
"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"
};
unsigned int i;
test_begin("message header encode");
str_truncate(str, 0);
}
test_end();
}
static void test_message_header_encode_data(void)
{
test_begin("message header encode data");
str_truncate(str, 0);
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}