~sircmpwn/aerc

Fix notmuch "mail: no address" message list v1 PROPOSED

Tamás Gulácsi
Tamás Gulácsi: 1
 Fix notmuch "mail: no address" message list

 2 files changed, 6 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/13065/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] Fix notmuch "mail: no address" message list Export this patch

Tamás Gulácsi
lib/format#ParseAddress needs the same empty address handling as ParseAddressList.
Also, provide more verbose error message in the UI.

Signed-off-by: Tamás Gulácsi <tamas@gulacsi.eu>
---
 lib/format/format.go | 6 +++++-
 widgets/msglist.go   | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/format/format.go b/lib/format/format.go
index 0eda7ae..ae9b411 100644
--- a/lib/format/format.go
+++ b/lib/format/format.go
@@ -2,6 +2,7 @@ package format

import (
	"errors"
	"fmt"
	"mime"
	gomail "net/mail"
	"strings"
@@ -13,9 +14,12 @@ import (
)

func ParseAddress(address string) (*models.Address, error) {
	if address == "" {
		return nil, nil
	}
	addrs, err := gomail.ParseAddress(address)
	if err != nil {
		return nil, err
		return nil, fmt.Errorf("parse %q: %w", address, err)
	}
	return (*models.Address)(addrs), nil
}
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 09b0868..6eb0c4d 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -154,7 +154,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
			uiConfig.IndexFormat,
			uiConfig.TimestampFormat, "", i, msg, store.IsMarked(uid))
		if err != nil {
			ctx.Printf(0, row, style, "%v", err)
			ctx.Printf(0, row, style, "ERROR: %+v", err)
		} else {
			line := fmt.Sprintf(fmtStr, args...)
			line = runewidth.Truncate(line, textWidth, "…")
-- 
2.28.0
I'm not sure about this. Returning nil, nil is a little misleading.

An empty address list is fine, but when the RFC says a field contains a
single address, I don't think it's valid to put an empty string?

Also this doesn't account for CFWS (comments and white-space).