summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2004-08-18 23:37:46 +0000
committerIan C <ianc@noddybox.co.uk>2004-08-18 23:37:46 +0000
commit718b54c985aa2fe7146df39176796ce4d6580504 (patch)
treea44723bc95caf07b108576c9d356821823818b6e /src
parent225ea435762b45016242332d665ee97bbb3313e2 (diff)
Fixed bug where an '@' in the quoted name in the From address would
break parsing.
Diffstat (limited to 'src')
-rw-r--r--src/pop3.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/pop3.c b/src/pop3.c
index 5d87e9a..0123b5f 100644
--- a/src/pop3.c
+++ b/src/pop3.c
@@ -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
{