diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-01-15 18:25:34 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-01-15 18:25:34 +0000 |
commit | 4b38ffd6c83438601284f75e351e1c0a2f4c57e7 (patch) | |
tree | 165d0d2c40b8a5e8162b9a79ca76f4252e571435 /rfc822.c | |
parent | 381ed5f6ff9e6fdf318371a48201ef502a98d36c (diff) | |
download | fetchmail-4b38ffd6c83438601284f75e351e1c0a2f4c57e7.tar.gz fetchmail-4b38ffd6c83438601284f75e351e1c0a2f4c57e7.tar.bz2 fetchmail-4b38ffd6c83438601284f75e351e1c0a2f4c57e7.zip |
Another step forwards.
svn path=/trunk/; revision=768
Diffstat (limited to 'rfc822.c')
-rw-r--r-- | rfc822.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -21,7 +21,7 @@ char *buf; /* header to be hacked */ const char *host; /* server hostname */ { const char *from; - int parendepth, state = 0, tokencount = 0; + int parendepth, oldstate, state = 0, tokencount = 0, nlterm = 0; char mycopy[POPBUFSIZE+1]; if (strncmp("From: ", buf, 6) @@ -33,7 +33,14 @@ const char *host; /* server hostname */ } strcpy(mycopy, buf); - strcat(mycopy, ","); + if (mycopy[strlen(mycopy) - 1] == '\n') + { + mycopy[strlen(mycopy) - 1] = '\0'; + nlterm = TRUE; + } + if (mycopy[strlen(mycopy) - 1] != ',') + strcat(mycopy, ","); + for (from = mycopy; *from; from++) { #ifdef FOO @@ -60,6 +67,7 @@ const char *host; /* server hostname */ else if (*from == '(') { parendepth = 1; + oldstate = 1; state = 4; } else if (*from == '<') @@ -91,7 +99,7 @@ const char *host; /* server hostname */ else if (*from == ')') --parendepth; if (parendepth == 0) - state = 1; + state = oldstate; break; case 5: /* we're in a <>-enclosed address */ @@ -110,6 +118,12 @@ const char *host; /* server hostname */ else if (*from == '<') state = 5; + else if (*from == '(') + { + oldstate = 6; + state = 4; + } + /* on proper termination with no @, insert hostname */ else if (*from == ',') { @@ -131,7 +145,13 @@ const char *host; /* server hostname */ continue; if (*cp == '(') { - INSERT_HOSTNAME + char *bp = strchr(cp, '<'); + char *ep = strchr(cp, ','); + + if (!bp || bp > ep) + { + INSERT_HOSTNAME + } } } @@ -154,6 +174,9 @@ const char *host; /* server hostname */ /* back up and nuke the appended comma sentinel */ *--buf = '\0'; + + if (nlterm) + strcat(buf, "\n"); } char *nxtaddr(hdr) |