diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | rfc822.c | 40 |
2 files changed, 28 insertions, 13 deletions
@@ -18,6 +18,7 @@ fetchmail-4.2.4 (Thu Sep 18 16:19:10 EDT 1997) * Small compilation cleanups, thanks to Florian laRoche. * Removed the length consistency check, it mysteriously fails under POP3. +* Added Alexander Kourakos's patch to improve address rewriting. fetchmail-4.2.3 (Thu Sep 18 16:19:10 EDT 1997) * Fix a bug in IMAP message-size retrieval. @@ -74,11 +74,14 @@ const char *host; /* server hostname */ * an obscure misfeature described in sections * 6.1, 6.2.6, and A.1.5 of the RFC822 standard. */ - else if ((*from == ',' || HEADER_END(from)) && has_bare_name_part && !has_host_part && from[-1] != ';') + else if ((*from == ',' || HEADER_END(from) || from[1] == '(') + && has_bare_name_part + && !has_host_part + && from[-1] != ';') { int hostlen; - while (isspace(*from)) + while (isspace(*from) || (*from == ',')) --from; from++; hostlen = strlen(host); @@ -86,7 +89,7 @@ const char *host; /* server hostname */ cp[hostlen+1] = *cp; *from++ = '@'; memcpy(from, host, hostlen); - from += strlen(from); + from += hostlen; has_host_part = TRUE; } else if (!isspace(*from)) @@ -101,20 +104,31 @@ const char *host; /* server hostname */ case 3: /* we're in a <>-enclosed address */ if (*from == '@') has_host_part = TRUE; - else if (*from == '>' && !has_host_part) + else if (*from == '>') { - int hostlen; - - hostlen = strlen(host); - for (cp = from + strlen(from); cp >= from; --cp) - cp[hostlen+1] = *cp; - *from++ = '@'; - memcpy(from, host, hostlen); - from += strlen(from); - has_host_part = TRUE; + state = 1; + if (!has_host_part) + { + int hostlen; + + hostlen = strlen(host); + for (cp = from + strlen(from); cp >= from; --cp) + cp[hostlen+1] = *cp; + *from++ = '@'; + memcpy(from, host, hostlen); + from += hostlen; + has_host_part = TRUE; + } } break; } + + /* + * If we passed a comma, reset everything. + */ + if (from[-1] == ',' && !parendepth) { + has_host_part = has_bare_name_part = FALSE; + } } } |