From 7052f7f510a90d1cce53bb1541ef99d092033503 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 19 Sep 1997 23:10:18 +0000 Subject: Alexander Kourakos's patch to improve rewriting. svn path=/trunk/; revision=1376 --- NEWS | 1 + rfc822.c | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index a449b069..0b906115 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/rfc822.c b/rfc822.c index b6103c8c..5e9e2da5 100644 --- a/rfc822.c +++ b/rfc822.c @@ -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; + } } } -- cgit v1.2.3