~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH aerc] rfc822: parse multipart messages on a best efforts basis

Details
Message ID
<20241107163423.1171676-1-koni.marti@gmail.com>
DKIM signature
pass
Download raw message
Patch: +12 -1
Parse multipart messages on a best efforts basis. If a multipart parsing
error occurs, display the message as a single text/plain part.
Currently, the user will only see an error in the message list. With
this change, the user can at least look at the "unparsed" message
content and see the message headers in the viewer.

The error will be logged and a warning prefix to the subject header is
added to make it obvious that aerc modified the message body structure.

Fixes: https://todo.sr.ht/~rjarry/aerc/288
Signed-off-by: Koni Marti <koni.marti@gmail.com>
---
 lib/rfc822/message.go | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/rfc822/message.go b/lib/rfc822/message.go
index 653cb2fe..43ef1943 100644
--- a/lib/rfc822/message.go
+++ b/lib/rfc822/message.go
@@ -119,7 +119,18 @@ func ParseEntityStructure(e *message.Entity) (*models.BodyStructure, error) {
			if errors.Is(err, io.EOF) {
				return &body, nil
			} else if err != nil {
				return nil, err
				// we don't return errors from parsing multipart
				// messages; we parse it on a best-efforts basis
				// as a single text/plain part.
				body.MIMEType = "text"
				body.MIMESubType = "plain"
				body.Params = map[string]string{"charset": "utf-8"}
				body.Parts = []*models.BodyStructure{}
				warning := "[aerc: multipart parsing error] "
				e.Header.Set("Subject", warning+e.Header.Get("Subject"))
				log.Warnf("multipart error (%v) caught: "+
					"parsing on a best-efforts basis", err)
				return &body, nil
			}
			ps, err := ParseEntityStructure(part)
			if err != nil {
-- 
2.47.0

[aerc/patches] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D5G3CRL8QR5K.2E4KDXKX4H7JE@fra02>
In-Reply-To
<20241107163423.1171676-1-koni.marti@gmail.com> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: FAILED in 1m35s

[rfc822: parse multipart messages on a best efforts basis][0] from [Koni Marti][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/55856
[1]: koni.marti@gmail.com

✗ #1365038 FAILED  aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/1365038
✓ #1365039 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/1365039
Details
Message ID
<D5G3KF116XC0.DJCPV7OFX6JB@mailbox.org>
In-Reply-To
<20241107163423.1171676-1-koni.marti@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Thu Nov 7, 2024 at 5:34 PM CET, Koni Marti wrote:
> Parse multipart messages on a best efforts basis. If a multipart parsing
> error occurs, display the message as a single text/plain part.
> Currently, the user will only see an error in the message list. With
> this change, the user can at least look at the "unparsed" message
> content and see the message headers in the viewer.
>
> The error will be logged and a warning prefix to the subject header is
> added to make it obvious that aerc modified the message body structure.
> [SNIP]


Can't speak for all but this does work for the broken messages I have.
Thanks :)

nit: IMO [aerc: multipart parsing error] in the title is too verbose and
I can hardly read the subject in the message list when the window is not
wide enough.

Tested-by: Tianhao Wang <shrik3@mailbox.org>

-- 
wth
220F 6A50 7BEF 8C33 3B4A 4404 99DE B3B4 1583 4AEF
Details
Message ID
<D5G3Q9EZ778U.2PI73626EQXR4@gmail.com>
In-Reply-To
<D5G3KF116XC0.DJCPV7OFX6JB@mailbox.org> (view parent)
DKIM signature
pass
Download raw message
On Thu Nov 7, 2024 at 5:46 PM CET, Tianhao Wang wrote:
> nit: IMO [aerc: multipart parsing error] in the title is too verbose and
> I can hardly read the subject in the message list when the window is not
> wide enough.

I'm open for a better prefix, if one at all.
Maybe "aerc: malformed message" or something even shorter.

> Tested-by: Tianhao Wang <shrik3@mailbox.org>

Thanks for testing!
Reply to thread Export thread (mbox)