Skip to content

Commit

Permalink
lib-mail: Refactor code to make the next commit smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and villesavolainen committed Mar 6, 2018
1 parent ba1ca97 commit 0510374
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/lib-mail/message-address.c
Expand Up @@ -400,9 +400,9 @@ message_address_parse_real(pool_t pool, const unsigned char *data, size_t size,

if (rfc822_skip_lwsp(&ctx.parser) <= 0) {
/* no addresses */
return NULL;
} else {
(void)parse_address_list(&ctx, max_addresses);
}
(void)parse_address_list(&ctx, max_addresses);
return ctx.first_addr;
}

Expand Down
30 changes: 13 additions & 17 deletions src/lib-mail/message-id.c
Expand Up @@ -9,6 +9,7 @@ static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid)
{
struct rfc822_parser_context parser;
int ret;
bool success = FALSE;

rfc822_parser_init(&parser, (const unsigned char *)*msgid_p,
strlen(*msgid_p), NULL);
Expand All @@ -27,23 +28,18 @@ static bool get_untokenized_msgid(const char **msgid_p, string_t *msgid)
ret = rfc822_parse_quoted_string(&parser, msgid);
else
ret = rfc822_parse_dot_atom(&parser, msgid);
if (ret <= 0)
return FALSE;

if (*parser.data != '@')
return FALSE;
str_append_c(msgid, '@');
parser.data++;
rfc822_skip_lwsp(&parser);

if (rfc822_parse_dot_atom(&parser, msgid) <= 0)
return FALSE;

if (*parser.data != '>')
return FALSE;

*msgid_p = (const char *)parser.data + 1;
return TRUE;
if (ret > 0 && *parser.data == '@') {
str_append_c(msgid, '@');
parser.data++;
rfc822_skip_lwsp(&parser);

if (rfc822_parse_dot_atom(&parser, msgid) > 0 &&
*parser.data == '>') {
*msgid_p = (const char *)parser.data + 1;
success = TRUE;
}
}
return success;
}

static void strip_lwsp(char *str)
Expand Down
5 changes: 2 additions & 3 deletions src/lib-mail/message-parser.c
Expand Up @@ -499,9 +499,8 @@ static void parse_content_type(struct message_parser_ctx *ctx,
ctx->part->flags |= MESSAGE_PART_FLAG_MULTIPART_DIGEST;
}

if (ret < 0)
return;
if ((ctx->part->flags & MESSAGE_PART_FLAG_MULTIPART) == 0 ||
if (ret < 0 ||
(ctx->part->flags & MESSAGE_PART_FLAG_MULTIPART) == 0 ||
ctx->last_boundary != NULL)
return;

Expand Down

0 comments on commit 0510374

Please sign in to comment.