Browse Source

ENGINE-558: scan from_address right-to-left searching for '@'

This should be enough to solve the problem.
ENGINE-558
Luca Saiu 3 weeks ago
parent
commit
8bc79db685
1 changed files with 13 additions and 5 deletions
  1. +13
    -5
      src/message_api.c

+ 13
- 5
src/message_api.c View File

@ -775,11 +775,19 @@ static PEP_STATUS generate_message_id(message* msg) {
size_t buf_len = 2; // NUL + @
char* from_addr = msg->from->address;
char* domain_ptr = strstr(from_addr, "@");
if (!domain_ptr || *(domain_ptr + 1) == '\0')
domain_ptr = "localhost";
else
domain_ptr++;
/* Look for the *last* occurrence of '@' within the string beginning at
from_addr; if no '@' exists or if it is at the very end then keep the
"localhost" default as domain. */
char *p;
char *domain_ptr = "localhost";
for (p = from_addr + strlen (from_addr); p >= from_addr; p --)
if (* p == '@')
{
if (p [1] != '\0')
domain_ptr = p + 1;
break;
}
buf_len += strlen(domain_ptr);


Loading…
Cancel
Save