]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Change MESSAGE_ADDRESS_PARSE_FLAG_NON_STRICT_DOTS to _FLAG_STRICT_DOTS
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 4 May 2018 16:53:27 +0000 (19:53 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Aug 2018 08:24:09 +0000 (11:24 +0300)
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.)

src/lib-mail/message-address.c
src/lib-mail/message-address.h
src/lib-mail/test-message-address.c

index fcd525e30993254aa7ee70ca7cf10c73a061a563..b1d2a14d1abfd2afeb2be954d2b3b7353b14118d 100644 (file)
@@ -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 */
index ec9b10f2f42fc5fe2364dd3524d5fd1a4cea0a7c..8370397741cbde6b90b9253ccd111d4b889829c8 100644 (file)
@@ -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:
index d46d2fc14b2e3f87d5da7b28a376fcd7f3cc19c0..e30bde2d15f0247ee31b72255c659083bd740930 100644 (file)
@@ -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);
        }