ref: feda48624bd8e5a321e81fbe19e45afa959d1367
parent: 79b4ec29a16c728d1918db4c7aa75379ab66d19e
author: cinap_lenrek <[email protected]>
date: Tue Sep 1 17:39:45 EDT 2020
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.
--- a/sys/src/cmd/upas/fs/cache.c
+++ b/sys/src/cmd/upas/fs/cache.c
@@ -77,6 +77,7 @@
}
free(m->unixfrom);
m->unixfrom = nil;
+ m->unixdate = nil;
free(m->unixheader);
m->unixheader = nil;
free(m->boundary);
--- a/sys/src/cmd/upas/fs/dat.h
+++ b/sys/src/cmd/upas/fs/dat.h
@@ -118,6 +118,7 @@
/* mail info */
char *unixheader;
char *unixfrom;
+ char *unixdate;
char *references[Nref]; /* nil terminated unless full */
/* mime info */
--- a/sys/src/cmd/upas/fs/mbox.c
+++ b/sys/src/cmd/upas/fs/mbox.c
@@ -365,7 +365,7 @@
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,7 +482,7 @@
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;
@@ -489,6 +489,7 @@
free(m->unixfrom);
m->unixfrom = strdup(s);
*p = ' ';
+ m->unixdate = ++p;
}
void
@@ -572,6 +573,8 @@
p = "???";
m->unixheader = smprint("From %s %Δ\n", p, m->fileid);
}
+ m->unixdate = nil;
+
m->cstate |= Cheader;
sanembmsg(mb, m);
}