aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-28 04:20:14 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-28 04:20:14 +0000
commitb48db48b0571aa8d79de05a2c91683aab9bc38b4 (patch)
tree5fb545332f549c456a4e34ef8e131e63f187e648
parent483da2f9e70d047684643780246671f2c9483330 (diff)
downloadfetchmail-b48db48b0571aa8d79de05a2c91683aab9bc38b4.tar.gz
fetchmail-b48db48b0571aa8d79de05a2c91683aab9bc38b4.tar.bz2
fetchmail-b48db48b0571aa8d79de05a2c91683aab9bc38b4.zip
Handle nested parentheses in RFC822 comments.
svn path=/trunk/; revision=404
-rw-r--r--driver.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/driver.c b/driver.c
index e549c5ed..e0cc56db 100644
--- a/driver.c
+++ b/driver.c
@@ -84,7 +84,7 @@ char *buf; /* header to be hacked */
const char *host; /* server hostname */
{
const char *from;
- int state = 0, tokencount = 0;
+ int parendepth, state = 0, tokencount = 0;
char mycopy[POPBUFSIZE+1];
if (strncmp("From: ", buf, 6)
@@ -109,7 +109,10 @@ const char *host; /* server hostname */
if (*from == '"')
state = 3;
else if (*from == '(')
+ {
+ parendepth = 1;
state = 4;
+ }
else if (*from == '<' || isalnum(*from))
state = 5;
else if (isspace(*from))
@@ -133,7 +136,11 @@ const char *host; /* server hostname */
break;
case 4: /* we're in a parenthesized human name, copy and ignore */
- if (*from == ')')
+ if (*from == '(')
+ ++parendepth;
+ else if (*from == ')')
+ --parendepth;
+ if (parendepth == 0)
state = 1;
break;
@@ -210,7 +217,8 @@ static char *nxtaddr(hdr)
char *hdr; /* header line to be parsed, NUL to continue in previous hdr */
{
static char *hp, *tp, address[POPBUFSIZE+1];
- static state;
+ static int state;
+ int parendepth;
/*
* Note 1: RFC822 escaping with \ is *not* handled. Note 2: it is
@@ -256,7 +264,10 @@ char *hdr; /* header line to be parsed, NUL to continue in previous hdr */
*tp++ = *hp;
}
else if (*hp == '(') /* address comment -- ignore */
+ {
+ parendepth = 1;
state = 3;
+ }
else if (*hp == '<') /* begin <address> */
{
state = 4;
@@ -286,7 +297,11 @@ char *hdr; /* header line to be parsed, NUL to continue in previous hdr */
case 3: /* we're in a parenthesized comment, ignore */
if (*hp == '\n')
return(NULL);
+ else if (*hp == '(')
+ ++parendepth;
else if (*hp == ')')
+ --parendepth;
+ if (parendepth == 0)
state = 1;
break;