Skip to content

Commit

Permalink
lib-mail: Change MESSAGE_ADDRESS_PARSE_FLAG_NON_STRICT_DOTS to _FLAG_…
Browse files Browse the repository at this point in the history
…STRICT_DOTS

Generally we want it to be enabled everywhere, so it's easier to just enable
it by default.

(This is kept as a separate commit from the previous one so it'll be easy to
revert this in case we actually don't want this to be the default.)
  • Loading branch information
sirainen committed Aug 30, 2018
1 parent 2a867dc commit 7d4c438
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lib-mail/message-address.c
Expand Up @@ -456,7 +456,7 @@ message_address_parse_real(pool_t pool, const unsigned char *data, size_t size,
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 */
Expand Down
10 changes: 5 additions & 5 deletions src/lib-mail/message-address.h
Expand Up @@ -7,11 +7,11 @@ enum message_address_parse_flags {
/* 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:
Expand Down
10 changes: 5 additions & 5 deletions src/lib-mail/test-message-address.c
Expand Up @@ -358,15 +358,15 @@ static void test_message_address_non_strict_dots(void)
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);
}
Expand Down

0 comments on commit 7d4c438

Please sign in to comment.