~sircmpwn/aerc

msgviewer: bypass filter for headers v1 PROPOSED

Reto Brunner: 2
 msgviewer: bypass filter for headers
 msgviewer: decode headers prior to displaying them

 2 files changed, 13 insertions(+), 4 deletions(-)
Tested, fixes half of #289 (:toggle-headers now shows properly decoded
values).

I've got it on my list to fix the other half (decode the from address in
format.go).

LGTM!
Thanks!

To git.sr.ht:~sircmpwn/aerc
   b2dc624..da6fb1a  master -> master
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/9448/mbox | git am -3
Learn more about email & git

[PATCH v1 1/2] msgviewer: bypass filter for headers Export this patch

---
 widgets/msgviewer.go | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 25bebfa..90d5100 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -585,18 +585,21 @@ func (pv *PartViewer) attemptCopy() {
		}
		go func() {
			if pv.showHeaders && pv.msg.RFC822Headers != nil {
				// header need to bypass the filter, else we run into issues
				// with the filter messing with newlines etc.
				// hence all writes in this block go directly to the pager
				fields := pv.msg.RFC822Headers.Fields()
				for fields.Next() {
					field := fmt.Sprintf(
						"%s: %s\n", fields.Key(), fields.Value())
					pv.sink.Write([]byte(field))
					pv.pagerin.Write([]byte(field))
				}
				// virtual header
				if len(pv.msg.Labels) != 0 {
					labels := fmtHeader(pv.msg, "Labels", "")
					pv.sink.Write([]byte(fmt.Sprintf("Labels: %s\n", labels)))
					pv.pagerin.Write([]byte(fmt.Sprintf("Labels: %s\n", labels)))
				}
				pv.sink.Write([]byte{'\n'})
				pv.pagerin.Write([]byte{'\n'})
			}

			entity, err := message.New(header, pv.source)
-- 
2.24.1

[PATCH v1 2/2] msgviewer: decode headers prior to displaying them Export this patch

---
 widgets/msgviewer.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 90d5100..6d313a7 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -590,8 +590,14 @@ func (pv *PartViewer) attemptCopy() {
				// hence all writes in this block go directly to the pager
				fields := pv.msg.RFC822Headers.Fields()
				for fields.Next() {
					var value string
					var err error
					if value, err = fields.Text(); err != nil {
						// better than nothing, use the non decoded version
						value = fields.Value()
					}
					field := fmt.Sprintf(
						"%s: %s\n", fields.Key(), fields.Value())
						"%s: %s\n", fields.Key(), value)
					pv.pagerin.Write([]byte(field))
				}
				// virtual header
-- 
2.24.1
Tested, fixes half of #289 (:toggle-headers now shows properly decoded
values).

I've got it on my list to fix the other half (decode the from address in
format.go).

LGTM!
Thanks!

To git.sr.ht:~sircmpwn/aerc
   b2dc624..da6fb1a  master -> master
View this thread in the archives