upas: appendfolder(): skip the address from unix header before date

This commit is contained in:
cinap_lenrek 2020-09-01 23:01:45 +02:00
parent feda48624b
commit 20d8cd0d63

View file

@ -186,8 +186,8 @@ mboxesc(Biobuf *in, Biobuf *out, int type)
int int
appendfolder(Biobuf *b, char *addr, int fd) appendfolder(Biobuf *b, char *addr, int fd)
{ {
char *s; char *s, *t;
int r, n; int r;
Biobuf bin; Biobuf bin;
Folder *f; Folder *f;
Tm tm; Tm tm;
@ -196,10 +196,11 @@ appendfolder(Biobuf *b, char *addr, int fd)
Bseek(f->out, 0, 2); Bseek(f->out, 0, 2);
Binit(&bin, fd, OREAD); Binit(&bin, fd, OREAD);
s = Brdstr(&bin, '\n', 0); s = Brdstr(&bin, '\n', 0);
n = strlen(s); if(s == nil || strncmp(s, "From ", 5) != 0)
if(!s || strncmp(s, "From ", 5) != 0)
Bprint(f->out, "From %s %.28s\n", addr, ctime(f->t)); Bprint(f->out, "From %s %.28s\n", addr, ctime(f->t));
else if(n > 5 && tmparse(&tm, Ctimefmt, s + 5, nil, nil) != nil) else if(strncmp(s, "From ", 5) == 0
&& (t = strchr(s + 5, ' ')) != nil
&& tmparse(&tm, Ctimefmt, t + 1, nil, nil) != nil)
f->t = tm2sec(&tm); f->t = tm2sec(&tm);
if(s) if(s)
Bwrite(f->out, s, strlen(s)); Bwrite(f->out, s, strlen(s));