diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-09-19 23:10:18 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-09-19 23:10:18 +0000 |
commit | 7052f7f510a90d1cce53bb1541ef99d092033503 (patch) | |
tree | f4d424d33990112216de891e78e6276ffd9b19d2 /rfc822.c | |
parent | 0dc147c15f787f2e381594b96e842d226504bfa4 (diff) | |
download | fetchmail-7052f7f510a90d1cce53bb1541ef99d092033503.tar.gz fetchmail-7052f7f510a90d1cce53bb1541ef99d092033503.tar.bz2 fetchmail-7052f7f510a90d1cce53bb1541ef99d092033503.zip |
Alexander Kourakos's patch to improve rewriting.
svn path=/trunk/; revision=1376
Diffstat (limited to 'rfc822.c')
-rw-r--r-- | rfc822.c | 40 |
1 files changed, 27 insertions, 13 deletions
@@ -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; + } } } |