upas/fs: extract proper date from unix header

do not try to parse the m->unixfrom field, it only contains
the unix mail address.

instead, have parseunix() save a pointer into the unixheader
after the unix mail address for the unixdate, and later use
it to derive the mails timestamp.
This commit is contained in:
cinap_lenrek 2020-09-01 21:39:45 +02:00
parent 79b4ec29a1
commit feda48624b
3 changed files with 7 additions and 2 deletions

View file

@ -77,6 +77,7 @@ cachefree(Mailbox *mb, Message *m)
}
free(m->unixfrom);
m->unixfrom = nil;
m->unixdate = nil;
free(m->unixheader);
m->unixheader = nil;
free(m->boundary);

View file

@ -118,6 +118,7 @@ struct Message {
/* mail info */
char *unixheader;
char *unixfrom;
char *unixdate;
char *references[Nref]; /* nil terminated unless full */
/* mime info */

View file

@ -365,7 +365,7 @@ datesec(Mailbox *mb, Message *m)
if(m->fileid > 1000000ull<<8)
return;
if(m->unixfrom && strtotm(m->unixfrom, &tm) >= 0)
if(m->unixdate && strtotm(m->unixdate, &tm) >= 0)
v = tm2sec(&tm);
else if(m->date822 && strtotm(m->date822, &tm) >= 0)
v = tm2sec(&tm);
@ -482,13 +482,14 @@ parseunix(Message *m)
char *s, *p;
m->unixheader = smprint("%.*s", utfnlen(m->start, m->header - m->start), m->start);
s = m->start + 5;
s = m->unixheader + 5;
if((p = strchr(s, ' ')) == nil)
return;
*p = 0;
free(m->unixfrom);
m->unixfrom = strdup(s);
*p = ' ';
m->unixdate = ++p;
}
void
@ -572,6 +573,8 @@ parseheaders(Mailbox *mb, Message *m, int addfrom, int justmime)
p = "???";
m->unixheader = smprint("From %s %Δ\n", p, m->fileid);
}
m->unixdate = nil;
m->cstate |= Cheader;
sanembmsg(mb, m);
}