diff --git a/Changelog.md b/Changelog.md index 15176672..912735bf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -40,6 +40,7 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/) * Issue causing deadlock when reloading users keys due to double-locking of a mutex. * Correctly handle failure to unlock single key. * GODT-479 Fix flaky integration tests. +* GODT-484 Fix infinite loop when decoding invalid 2231 charset ## [v1.2.7] Donghai-hotfix - beta (2020-05-07) diff --git a/pkg/mime/encoding_test.go b/pkg/mime/encoding_test.go index 5705792a..7fa91e49 100644 --- a/pkg/mime/encoding_test.go +++ b/pkg/mime/encoding_test.go @@ -107,6 +107,11 @@ func TestParseMediaType(t *testing.T) { wantMediaType: "attachment", wantParams: map[string]string{"filename": "備a忘b錄.m4a", "title": "memorandum"}, }, + "Bad2231EncodingKeepsJustTitle": { + arg: "attachment;\nfilename*=utf-8'%F0%9F%98%81%F0%9F%98%82.txt;\n title=smile", + wantMediaType: "attachment", + wantParams: map[string]string{"title": "smile"}, + }, } for name, testData := range testTable { t.Run(name, testData.run) diff --git a/pkg/mime/mediaType.go b/pkg/mime/mediaType.go index 6eb1a84c..f5ec2ad2 100644 --- a/pkg/mime/mediaType.go +++ b/pkg/mime/mediaType.go @@ -69,6 +69,7 @@ func changeEncodingAndKeepLastParamDefinition(v string) (out string, err error) charset, _, err := get2231Charset(value) if err != nil { log.Errorln("Filter params:", err) + v = rest continue } if charset != "utf-8" && charset != "us-ascii" {