aboutsummaryrefslogtreecommitdiffstats
path: root/rfc822.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-09-19 23:10:18 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-09-19 23:10:18 +0000
commit7052f7f510a90d1cce53bb1541ef99d092033503 (patch)
treef4d424d33990112216de891e78e6276ffd9b19d2 /rfc822.c
parent0dc147c15f787f2e381594b96e842d226504bfa4 (diff)
downloadfetchmail-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.c40
1 files changed, 27 insertions, 13 deletions
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;
+ }
}
}