summaryrefslogtreecommitdiff
path: root/sys/src/cmd/upas/fs
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-09-01 21:39:45 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-09-01 21:39:45 +0200
commitfeda48624bd8e5a321e81fbe19e45afa959d1367 (patch)
treeab5382421d13d05cebe3239bfb653a1d63eeeaf6 /sys/src/cmd/upas/fs
parent79b4ec29a16c728d1918db4c7aa75379ab66d19e (diff)
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.
Diffstat (limited to 'sys/src/cmd/upas/fs')
-rw-r--r--sys/src/cmd/upas/fs/cache.c1
-rw-r--r--sys/src/cmd/upas/fs/dat.h1
-rw-r--r--sys/src/cmd/upas/fs/mbox.c7
3 files changed, 7 insertions, 2 deletions
diff --git a/sys/src/cmd/upas/fs/cache.c b/sys/src/cmd/upas/fs/cache.c
index 2b82e7967..1624835d9 100644
--- a/sys/src/cmd/upas/fs/cache.c
+++ b/sys/src/cmd/upas/fs/cache.c
@@ -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);
diff --git a/sys/src/cmd/upas/fs/dat.h b/sys/src/cmd/upas/fs/dat.h
index 85958d638..d94479162 100644
--- a/sys/src/cmd/upas/fs/dat.h
+++ b/sys/src/cmd/upas/fs/dat.h
@@ -118,6 +118,7 @@ struct Message {
/* mail info */
char *unixheader;
char *unixfrom;
+ char *unixdate;
char *references[Nref]; /* nil terminated unless full */
/* mime info */
diff --git a/sys/src/cmd/upas/fs/mbox.c b/sys/src/cmd/upas/fs/mbox.c
index 7bb58b555..5b57dba41 100644
--- a/sys/src/cmd/upas/fs/mbox.c
+++ b/sys/src/cmd/upas/fs/mbox.c
@@ -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);
}