]> git.lizzy.rs Git - plan9front.git/commitdiff
upas/fs: extract proper date from unix header
authorcinap_lenrek <cinap_lenrek@felloff.net>
Tue, 1 Sep 2020 19:39:45 +0000 (21:39 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Tue, 1 Sep 2020 19:39:45 +0000 (21:39 +0200)
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.

sys/src/cmd/upas/fs/cache.c
sys/src/cmd/upas/fs/dat.h
sys/src/cmd/upas/fs/mbox.c

index 2b82e7967dc32f02baaf0f627ecb4c15ddb1870a..1624835d91bf54110e31154c3b5d4141c9622e96 100644 (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);
index 85958d638a8485bb4b1f36cb7dc5367b961babfa..d94479162a68476cfabb37f952acfd32df2f5174 100644 (file)
@@ -118,6 +118,7 @@ struct Message {
        /* mail info */
        char    *unixheader;
        char    *unixfrom;
+       char    *unixdate;
        char    *references[Nref]; /* nil terminated unless full */
 
        /* mime info */
index 7bb58b5552b3163ca2cd61e91fdf5c7cb1979c79..5b57dba41c3d4a3f2c27abf289f74b035b84586c 100644 (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);
 }