aboutsummaryrefslogtreecommitdiffstats
path: root/worker/lib/parse_test.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-06-02 14:43:34 +0200
committerRobin Jarry <robin@jarry.cc>2022-06-07 16:19:27 +0200
commit955f7683af104b98ec67ef259f0cbe4c8f2a52ed (patch)
tree61e08f711914fd25cb65ceccb5636cf74692f00c /worker/lib/parse_test.go
parent8b6f9719a84fa0ee31d84b9e864495af4f166d92 (diff)
downloadaerc-955f7683af104b98ec67ef259f0cbe4c8f2a52ed.tar.gz
parse: fix content-type parsing error
If an error occurs when parsing the content-type, check if the content-type is quoted; if so, remove quotes. If this is not the case, then return a text/plain content-type as a sane fallback option, so that the message can be at least viewed in plaintext. Fixes: https://todo.sr.ht/~rjarry/aerc/44 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/lib/parse_test.go')
-rw-r--r--worker/lib/parse_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/worker/lib/parse_test.go b/worker/lib/parse_test.go
index 12190981..7e5bb367 100644
--- a/worker/lib/parse_test.go
+++ b/worker/lib/parse_test.go
@@ -10,6 +10,31 @@ import (
"git.sr.ht/~rjarry/aerc/models"
)
+func TestMessageInfoParser(t *testing.T) {
+ rootDir := "testdata/message/valid"
+ msgFiles, err := ioutil.ReadDir(rootDir)
+ die(err)
+
+ for _, fi := range msgFiles {
+ if fi.IsDir() {
+ continue
+ }
+
+ p := fi.Name()
+ t.Run(p, func(t *testing.T) {
+ m := newMockRawMessageFromPath(filepath.Join(rootDir, p))
+ mi, err := MessageInfo(m)
+ if err != nil {
+ t.Fatal("Failed to create MessageInfo with:", err)
+ }
+
+ if perr := mi.Error; perr != nil {
+ t.Fatal("Expected no parsing error, but got:", mi.Error)
+ }
+ })
+ }
+}
+
func TestMessageInfoHandledError(t *testing.T) {
rootDir := "testdata/message/invalid"
msgFiles, err := ioutil.ReadDir(rootDir)