ctx.pool = pool;
ctx.str = t_str_new(128);
ctx.fill_missing = (flags & MESSAGE_ADDRESS_PARSE_FLAG_FILL_MISSING) != 0;
- ctx.non_strict_dots = (flags & MESSAGE_ADDRESS_PARSE_FLAG_NON_STRICT_DOTS) != 0;
+ ctx.non_strict_dots = (flags & MESSAGE_ADDRESS_PARSE_FLAG_STRICT_DOTS) == 0;
if (rfc822_skip_lwsp(&ctx.parser) <= 0) {
/* no addresses */
/* If enabled, missing mailbox and domain are set to MISSING_MAILBOX
and MISSING_DOMAIN strings. Otherwise they're set to "". */
MESSAGE_ADDRESS_PARSE_FLAG_FILL_MISSING = BIT(0),
- /* Allow local-part to contain any number of dots anywhere in it.
- For example ".user", "us..ser" and "user." will be valid. This
- isn't strictly allowed by RFC5322, but these addresses are commonly
- used in Japan. */
- MESSAGE_ADDRESS_PARSE_FLAG_NON_STRICT_DOTS = BIT(1),
+ /* Require local-part to strictly adhere to RFC5322 when parsing dots.
+ For example ".user", "us..ser" and "user." will be invalid. This
+ isn't enabled by default, because these kind of invalid addresses
+ are commonly used in Japan. */
+ MESSAGE_ADDRESS_PARSE_FLAG_STRICT_DOTS = BIT(1),
};
/* group: ... ; will be stored like:
for (unsigned int i = 0; i < N_ELEMENTS(inputs); i++) {
const unsigned char *addr_input =
(const unsigned char *)inputs[i];
- /* invalid without non-strict-dots flag */
+ /* invalid with strict-dots flag */
addr = message_address_parse(pool_datastack_create(),
- addr_input, strlen(inputs[i]), UINT_MAX, 0);
+ addr_input, strlen(inputs[i]), UINT_MAX,
+ MESSAGE_ADDRESS_PARSE_FLAG_STRICT_DOTS);
test_assert_idx(addr != NULL && addr->invalid_syntax, i);
- /* valid with the non-strict-dots flag */
+ /* valid without the strict-dots flag */
addr = message_address_parse(pool_datastack_create(),
- addr_input, strlen(inputs[i]), UINT_MAX,
- MESSAGE_ADDRESS_PARSE_FLAG_NON_STRICT_DOTS);
+ addr_input, strlen(inputs[i]), UINT_MAX, 0);
output.mailbox = t_strcut(inputs[i], '@');
test_assert_idx(addr != NULL && cmp_addr(addr, &output), i);
}