diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-10-28 04:20:14 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-10-28 04:20:14 +0000 |
commit | b48db48b0571aa8d79de05a2c91683aab9bc38b4 (patch) | |
tree | 5fb545332f549c456a4e34ef8e131e63f187e648 | |
parent | 483da2f9e70d047684643780246671f2c9483330 (diff) | |
download | fetchmail-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.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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; |