aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-04-13 21:15:56 +0200
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:47:50 +0200
commit1b912fbbe98ae9b0a78da2b448f6121944d9b9b1 (patch)
treea86d8b0d4909d7abff4d96e75ec8151c57d4b430
parent535e7fe3aa50dc56af6449673d13ca0c0ac4e961 (diff)
downloadaerc-1b912fbbe98ae9b0a78da2b448f6121944d9b9b1.tar.gz
aerc-1b912fbbe98ae9b0a78da2b448f6121944d9b9b1.zip
compose: explicitly identify converted text/* parts
When running :accept, an error is displayed on the review screen: text/calendar error: no command defined for mime/type When running :multipart text/xxx, its contents are not specified. They are regenerated every time the review screen is displayed. When running :accept, a text/calendar part is added with actual contents. Update the Part object to hold a boolean initialized when first being created. If body is nil, identify the part as "Converted" and update its contents every time the review screen is displayed. When body is not nil but contains text (e.g. when running :accept), identify the part as *not* converted and ignore the conversion step. Fixes: cbcabfafaab2 ("compose: allow writing multipart/alternative messages") Reported-by: Inwit <inwit@sindominio.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
-rw-r--r--app/compose.go5
-rw-r--r--commands/compose/multipart.go3
-rw-r--r--lib/attachment.go21
3 files changed, 20 insertions, 9 deletions
diff --git a/app/compose.go b/app/compose.go
index 22d862aa..9f9ebf39 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -1787,7 +1787,10 @@ func (c *Composer) updateMultipart(p *lib.Part) error {
p.ConversionError = e
return e
}
-
+ if !p.Converted {
+ // text/* multipart created without a command (e.g. by :accept)
+ return nil
+ }
command, found := config.Converters[p.MimeType]
if !found {
// unreachable
diff --git a/commands/compose/multipart.go b/commands/compose/multipart.go
index 13fe8ca3..a38e0a6e 100644
--- a/commands/compose/multipart.go
+++ b/commands/compose/multipart.go
@@ -1,7 +1,6 @@
package compose
import (
- "bytes"
"fmt"
"git.sr.ht/~rjarry/aerc/app"
@@ -52,7 +51,7 @@ func (m Multipart) Execute(args []string) error {
map[string]string{"Charset": "UTF-8"},
// the actual content of the part will be rendered
// every time the body of the email is updated
- bytes.NewReader([]byte{}),
+ nil,
)
if err != nil {
return err
diff --git a/lib/attachment.go b/lib/attachment.go
index 6f29da55..a5f1b034 100644
--- a/lib/attachment.go
+++ b/lib/attachment.go
@@ -19,19 +19,28 @@ type Part struct {
MimeType string
Params map[string]string
Data []byte
+ Converted bool
ConversionError error
}
func NewPart(mimetype string, params map[string]string, body io.Reader,
) (*Part, error) {
- d, err := io.ReadAll(body)
- if err != nil {
- return nil, err
+ var d []byte
+ var err error
+ var converted bool
+ if body == nil {
+ converted = true
+ } else {
+ d, err = io.ReadAll(body)
+ if err != nil {
+ return nil, err
+ }
}
return &Part{
- MimeType: mimetype,
- Params: params,
- Data: d,
+ MimeType: mimetype,
+ Params: params,
+ Data: d,
+ Converted: converted,
}, nil
}