diff options
author | Ian C <ianc@noddybox.co.uk> | 2004-08-18 23:37:46 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2004-08-18 23:37:46 +0000 |
commit | 718b54c985aa2fe7146df39176796ce4d6580504 (patch) | |
tree | a44723bc95caf07b108576c9d356821823818b6e | |
parent | 225ea435762b45016242332d665ee97bbb3313e2 (diff) |
Fixed bug where an '@' in the quoted name in the From address would
break parsing.
-rw-r--r-- | src/pop3.c | 39 |
1 files changed, 35 insertions, 4 deletions
@@ -93,6 +93,21 @@ static void Chomp(char *p) */ +static char *ChompChar(char *p, char c) +{ + size_t l; + + l=strlen(p); + + while (l && p[l-1]==c) + { + p[--l]=0; + } + + return p; +} + + static char *ChompQuotesWS(char *p) { size_t l; @@ -350,6 +365,7 @@ static void ParseHeader(POP3Message *msg, char *line) }; const char *name; + char *p; int f; int type=HDR_UNKNOWN; @@ -368,16 +384,31 @@ static void ParseHeader(POP3Message *msg, char *line) break; case HDR_FROM: - if (strchr(line,'<')) + if ((p=strchr(line,'<'))) { char *t[3]; - for(f=0;f<3 && t[f-1];f++) - t[f]=strtok(f==0 ? line:NULL,"<>@"); + /* Store up to the opening '<' + */ + t[0]=line; + *p=0; + + /* The uname must start here... + */ + t[1]=++p; + + /* Search for the @ + */ + t[2]=strchr(t[1],'@'); + + if (t[2]) + { + *t[2]++=0; + } msg->from=CopyStr(t[0] ? ChompQuotesWS(t[0]) : "UNKNOWN"); msg->from_uname=CopyStr(t[1] ? t[1] : "UNKNOWN"); - msg->from_domain=CopyStr(t[2] ? t[2] : "UNKNOWN"); + msg->from_domain=CopyStr(t[2] ? ChompChar(t[2],'>'):"UNKNOWN"); } else { |