talloc_set_allocator(malloc_wrapper, free_wrapper, realloc_wrapper);
}
-void check_header(struct rfc822_msg *msg, struct rfc822_header *h,
+void check_header(struct rfc822_msg *msg,
+ struct rfc822_header *h,
const char *name, const char *val,
- int crlf)
+ enum rfc822_header_errors experr, int crlf)
{
+ enum rfc822_header_errors errs;
struct bytestring hname, hvalue, hfull;
size_t namelen = strlen(name);
size_t valuelen = strlen(val);
size_t nln = crlf ? 2 : 1;
size_t fulllen = namelen + valuelen + 1 + nln;
- ok(rfc822_header_errors(msg, h) == 0, "Header valid");
+ errs = rfc822_header_errors(msg, h);
+ ok(errs == experr, "Header errors 0x%x != 0x%x", errs, experr);
allocation_failure_check();
hname = rfc822_header_raw_name(msg, h);
#define CHECK_HEADER_NUMTESTS 4
void check_header(struct rfc822_msg *msg, struct rfc822_header *h,
const char *name, const char *val,
- int crlf);
+ enum rfc822_header_errors experr, int crlf);
if (!(_h)) \
break; \
check_header((_msg), (_h), (_e)->hdrs[_i].name, \
- (_e)->hdrs[_i].val, crlf); \
+ (_e)->hdrs[_i].val, \
+ (_e)->hdrs[_i].errors, crlf); \
} \
} while (0)
struct testhdr {
const char *name, *val;
+ enum rfc822_header_errors errors;
};
struct aexample {
const char test_msg_space_body_body[] = " Message with LWS at start of body\n";
AEXAMPLE(test_msg_space_body);
+struct testhdr bad_hdrs_hdrs[] = {
+ {"From", "Mister From <from@example.com>"},
+ {"To", "Mizz To <to@example.org>"},
+ {"X-Bad-\bName", "This header field has bad characters in the name",
+ .errors = RFC822_HDR_BAD_NAME_CHARS},
+ {"Subject", "Some subject"},
+ {"Message-ID", "<20110221131559.GA28327@example>"},
+};
+#define bad_hdrs_body test_msg_1_body
+AEXAMPLE(bad_hdrs)
+
#define for_each_aexample(_e) \
foreach_ptr((_e), &test_msg_1, &test_msg_empty_body, \
&test_msg_nlnl_lf, &test_msg_nlnl_crlf, \
&test_msg_nlnl_mixed, \
- &test_msg_space_body)
+ &test_msg_space_body, \
+ &bad_hdrs)
#define for_each_aexample_buf(_e, _buf, _len) \
for_each_aexample((_e)) \