diff options
author | Ori Bernstein <ori@eigenstate.org> | 2020-10-17 18:59:36 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2020-10-17 18:59:36 -0700 |
commit | a41b74059bcb40e7fc37f3da72758b89cde4c437 (patch) | |
tree | 76c8d649260ca4115c6732fd28dc040abf035931 /sys/src/cmd/upas/common | |
parent | d310da13ba8d31c84978f96f542b9929a4e54ed8 (diff) |
upas: fix appendfolder timestamps (thanks umbraticus)
When moving messages between folders, mbappend,
deliver, and nedmail were trying to parse the
timestamp ouut of the message. They were doing
it incorrectly, trying to include the user name
as part of the date format.
Change to pass just the date to the date parser.
Diffstat (limited to 'sys/src/cmd/upas/common')
-rw-r--r-- | sys/src/cmd/upas/common/folder.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/sys/src/cmd/upas/common/folder.c b/sys/src/cmd/upas/common/folder.c index f16e2212c..0e39b9ddd 100644 --- a/sys/src/cmd/upas/common/folder.c +++ b/sys/src/cmd/upas/common/folder.c @@ -184,8 +184,8 @@ mboxesc(Biobuf *in, Biobuf *out, int type) int appendfolder(Biobuf *b, char *addr, int fd) { - char *s; - int r, n; + char *s, *t; + int r; Biobuf bin; Folder *f; Tzone *tz; @@ -194,15 +194,27 @@ appendfolder(Biobuf *b, char *addr, int fd) f = getfolder(b); Bseek(f->out, 0, 2); Binit(&bin, fd, OREAD); + s = Brdstr(&bin, '\n', 0); - n = strlen(s); - if(!s || strncmp(s, "From ", 5) != 0){ + + /* Unix from */ + if(s != nil && strncmp(s, "From ", 5) == 0 + && (t = strchr(s + 5, ' ')) != nil + && tmparse(&tm, Timefmt, t + 1, nil, nil) != nil){ + f->t = tmnorm(&tm); + }else { + /* + * Old mailboxes have dates in ctime format, + * which contains ambiguous timezone names. + * Passing in the local timezone has the side + * effect of disambiguating the timezone name + * as local. + */ tz = tzload("local"); tmtime(&tm, f->t, tz); Bprint(f->out, "From %s %τ\n", addr, tmfmt(&tm, Timefmt)); - }else if(n > 5 && tmparse(&tm, Timefmt, s + 5, nil, nil) != nil) - f->t = tmnorm(&tm); - if(s) + } + if(s != nil) Bwrite(f->out, s, strlen(s)); free(s); r = mboxesc(&bin, f->out, f->type); |